我正在尝试从查询字符串中获取数据,但将其与 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 调用吗?
提前致谢
我可以让它正确返回,但不是以 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>';
  }