gpt4 book ai didi

Ajax 调用失败。使用Jquery .ajax函数发出简单请求

转载 作者:行者123 更新时间:2023-12-01 05:05:51 24 4
gpt4 key购买 nike

这是调用ajax函数的jquery:

   function sendAjax(type, succ){  //where succ is the success callback

if (type=="")
{
$("#txtResp").empty();
return;
}

if(succ === undefined) { succ = null; }

switch(type)
{
case 'run':
$.ajax({type:"GET",
url: "start_mess.php",
data: "q="+type,
success: succ
});
break;
}

}

这是index.html页面内容:

    function initialLoad() 
{
sendAjax('run')
$("#txtResp").html(responseText);
}

initialLoad();

这是 PHP 页面:

echo $_GET['q'];
$q = $_GET['q'];

知道为什么这不起作用吗?谢谢!

泰勒

最佳答案

您没有传递回调,因此成功后无需调用任何内容。

尝试 sendAjax('run', function(data) {alert(data) });

关于Ajax 调用失败。使用Jquery .ajax函数发出简单请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5986349/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com