开发者

Facebook Javascript FB.api - callback not called on error

I've a problem with FB.api

I'm making a call to create an event something along the lines of:

 FB.api('/me/events', 'post', {
    access_token: $('#access_token').attr('value'),
    name: td.find('#event_name').attr('value'),
    description: td.find('#description').attr('value'),
    start_time: td.find('#event_start').attr('value'),
    end_time: td.find('#event_end').attr('value'),
    street: td.find('#venue_street').attr('value'),
    city: td.find('#venue_city').attr('value'),
    country: td.find('#venue_country').attr('value')
    }, function(response){
        console.log(response);
});

It works fine until e.g. 'city' is a non-existant city; then the callback function never gets called.

If I examine the AJAX request made using the net panel of firebug, I see the following was the response:

FB.ApiServer._callbacks.f37cab142051f02({
    "error": {
      "type": "Exception",
      "message": "(#151) Unknown city"
    }
}); 

The docs seem to show that I'm doing it right: http://developers.facebook.com/docs/reference/javascript/FB.api

Anyone why the callback function doesn't get called, and how I 开发者_如何转开发can catch the error?


To answer why the callback doesn't get called: The appropriate callback is being executed for me in Chrome, but not Firefox, so I think it has to do with the way the callbacks are handled for an HTTP 500 response in some browsers.

You'll also see the callback is being registered properly, if you manually run that response in your JavaScript console it should handle the error appropriately.

Still not sure how to get it working though, I suspect there will need to be updates the the JavaScript SDK.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜