当用户单击链接时,我正在尝试从 PHP 页面加载内容:
用户可以点击链接获取文件中的AJAX数据:message.php
我目前有这个代码message.php
$('#pmid<?php echo $convoData['id']; ?>').click(function(){
$.ajax({
type:"GET", //this is the default
url: "/index.php?i=pm&p=rr",
data: {id:"<?php echo $convoData['id']; ?>"}
})
.done(function( stuff ) {
$( "#name" ).html( stuff );
$( "#post" ).html( otherstuff );
$( "")
});
});
和 HTML:
Chat with <span id="name"></span> //The $name should be added to here
<ul id="post"></ul> //The $post should be added to here
AJAX 从中获取数据的页面被命名为:get.php,它看起来像这样:
$id = $_GET['id'];
$get=mysql_query("SELECT * FROM private_messages WHERE id='$id'");
$getData=mysql_fetch_assoc($get);
//Set the variables that needs to be send back to the other page.
$getUser=$user->getUserData($getData['sender_id']);
$name=$getUser['username'];
$post = '
<li>
<img width="30" height="30" src="images/avatar-male.jpg">
<div class="bubble">
<a class="user-name" href="">'.$name.'</a>
<p class="message">
'.$getData['subject'].'
</p>
<p class="time">
</p>
</div>
</li>
';
echo $name;
echo $post;
所以,问题是目前所有的数据都只是打印在#name
我该怎么做才能$name
将遗嘱打印在#name
里面?$post
#post