ユーザーがリンクをクリックしたときに、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
will が inとin$name
に印刷されるようにするにはどうすればよいですか?#name
$post
#post