0

別の 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

ここに画像の説明を入力

では、なぜ機能しないのですか?

4

1 に答える 1

0

requesttype を からPOSTに変更しただけGETで、うまくいきました。

于 2013-01-14T09:04:46.983 に答える