weixin_33744141 2013-11-08 21:10 采纳率: 0%
浏览 36

jQuery无法从Ajax运行

Guys i have a big problem, I have this jquery (I think) code, this code doesn't works from the ajax, and I don't know why, maybe someone can help me.

function showname(id){
    $.ajax({
       url:'tooltip.php',
       data:{id:id},
       async: false,
       success:function(response)
       {
          // use response for tooltip
          alert(response);
       }
    });
});
}

I put an alert on the php code, and the php code works when I call from url (like http://mysite.com/tooltip.php?id=LNFC without " ' ") that code must return the result of the query done on php code.

Php code

<?php 
$q="SELECT complete_name from mytable where id='".$_REQUEST['id']."'" or die(mysql_error()); 
$result=mysql_query($q,$conection); 
$row=mysql_fetch_assoc($result); 
echo $row['complete_name']; 
?>

Thanks.

  • 写回答

1条回答 默认 最新

  • weixin_33728708 2013-11-08 21:19
    关注

    Try this instead:

    function showname(id){
        $.ajax({
           type:'POST',
           url:'tooltip.php',
           data:{id:id},
           success:function(response) {
              // use response for tooltip
              alert(response);
           },
           error:function(response) {
               alert(response.errorThrown); 
           }
        });
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记