我想從查詢字符串中獲取我的數據,但使用它與Ajax。 我不能似乎得到的數據正確地傳遞,我想知道我的語法是錯誤的:
$(function()
{
$("#link").click(function(event)
{
event.preventDefault();
$.get("request.php",{id:+link.attr('id')},function(response){
$("#ajaxresponse div").fadeOut("fast", function()
{
$("#ajaxresponse div").remove();
$("#ajaxresponse").append($(response).hide().fadeIn());
});
}
});
return false;
});
});
HTML頁面代碼:
<div class="content">
<a href="request.php?id=1" id="link">
</div>
我不是數據正確地構建以Ajax調用??
在此先感謝
我能得到正常的回報,而不是在阿賈克斯的方式,它仍然加載PHP頁面,而不是其附加的,這裏是東西方request.php:
$username = $_GET['id'];
echo getTemplate($username);
function getTemplate($username)
{
return '<div class="box">
<h1>ID is</h1>
<div class="meta">username: '.$username.'</div>
</div>';
}
感謝您的幫助! – Jjames
@Jjames我很好,我可以幫你 – mgraph