別の ajax 呼び出しの成功の中で ajax 呼び出しを行おうとしています。これは完全に機能して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 呼び出しが正常に機能し、php スクリプトからの応答として(parent)
返さInsertFriends
れます。if 条件に存在する ajax リクエストがInsertFriends
正しく機能せず、xhr.responseText
空の文字列です。なぜそれが適切に機能しないのか、今ではわかりません。簡単にするためabc
に、サーバー側のスクリプトでエコーしましたが、何が問題なのかわかりません。
に次のエラーが表示されますChrome Network Tab
。
では、なぜ機能しないのですか?