Javascript 另一个ajax调用的success函数中的Jquery ajax调用不起作用,并且没有正确地告知错误类型
我试图在另一个ajax调用成功的情况下进行ajax调用。 这在Javascript 另一个ajax调用的success函数中的Jquery ajax调用不起作用,并且没有正确地告知错误类型,javascript,jquery,Javascript,Jquery,我试图在另一个ajax调用成功的情况下进行ajax调用。 这在localhost中工作得很好,但在服务器上却不行 这就是我正在做的 FB.api('/me', function(response) { $.ajax({ type:"POST", url:"http://gagsterz.com/index.php/home/InsertUser",
localhost
中工作得很好,但在服务器上却不行
这就是我正在做的
FB.api('/me', function(response) {
$.ajax({
type:"POST",
url:"http://gagsterz.com/index.php/home/InsertUser",
data:{id: response.id,name:response.name,at:self.access_token},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.responseText);
$('#error').html(xhr.responseText);
},
success:function(data)
{
FB.api('/me/friends',function(response) {
if(response.data)
{
countfriends = 0;
filedata="";
self.friendsID = new Array();
self.friendsName = new Array();
$.each(response.data,function(index,friend) {
filedata+=friend.id+"\t"+friend.name+"\t"+self.UID+"\n";
countfriends++;
self.friendsID.push(friend.id);
self.friendsName.push(friend.name);
});
if($.trim(data)=="InsertFriends")
{
$.ajax({
url:"http://gagsterz.com/index.php/home/InsertFBFriends",
type:"POST",
data: {fdata : filedata },
success:function(r)
{
alert("success");
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.responseText); },
});
}
});
});
现在,当我单击按钮时。第一个ajax调用(父级)
工作正常,并返回我InsertFriends
,作为php脚本的答案。现在,if条件下的InsertFriends
中的ajax请求无法正常工作,xhr.responseText
为空字符串。现在我不知道为什么它不能正常工作。简单地说,我只是在服务器端脚本上重复了abc
,但我不知道这有什么问题
我在Chrome网络标签中发现以下错误
那么为什么它不工作呢?我只是将requesttype从
POST
更改为GET
,它就工作了 尝试创建一个单独的函数,并将函数名作为成功。好的,我尝试了。你的建议有效过一次,下一次我尝试时,它给出了相同的错误,现在它又给了我错误,它只有效过一次。很抱歉,我无法访问解决类似问题的源代码。我很惊讶它只工作过一次,然后就停止了。我想问题可能在别的地方。响应代码200可以吗?它说已取消
,并且在jquery文件中给出了错误。如果您能够访问该代码,我将继续尝试。请让我知道,并向thnx寻求帮助。