douqiao7958 2014-05-07 16:07
浏览 13
已采纳

Jquery $ .get()和$ .ajax()没有得到相同的结果

I use the two different AJAX way to send/receive data from php file but can't get the same result

data.php

<?php
echo "hello";
?>

$.get()

if($(this).val() != '')
{
  $.get(
  'data.php',
  { what: $(this).val() },
  function(data)
  {
    $('#result').html(data);
    alert(data);
  });
}

$.ajax()

$('#choice').change(function()
{
  if($(this).val() != '')
  {
    $.ajax({type: GET, url: "data.php", complete: function(){alert("complete");}, success: function(data){alert(data);}, error: function(){alert("error");}});
});
}

.get() will return "hello" while .ajax() return nothing even no error.

  • 写回答

1条回答 默认 最新

  • drwn65609 2014-05-07 16:08
    关注

    You need to wrap GET inside quotes:

    type: "GET"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置