jquery's ajax not working in facebook apps

前端 未结 3 356
无人及你
无人及你 2021-01-13 12:19

I am trying to create a facebook application, all is working fine except the ajax part that I am using to populate a second box from the item selected in first select box.

相关标签:
3条回答
  • 2021-01-13 12:50

    You are not allowed to request data from other sites than the domain the script is running on. For example, if you are running the script www.example.com/script.js, then you can only ajax files under the www.exaple.com domain, not www.facebook.com.

    There are a few ways to do it:

    • JSONp is a way, but it requires that facebook replies with jsonp data. Not sure if it does. More info on JSONp here.
    • CSSHttpRequest (or AJACSS) is another way. Seriously doubt facbook uses this method.
    0 讨论(0)
  • 2021-01-13 12:55

    There is a limitation when using ajax that the xmlhttp request may not be cross-domain. See https://developer.mozilla.org/En/Same_origin_policy_for_JavaScript

    A common workaround for this is to make the ajax request to a backend script that will actually make the cross-domain request i.e. cURL.

    0 讨论(0)
  • 2021-01-13 12:57

    Using FBML you can use FBJS to send JSON data type to your own script:

    Here is the documentation: http://wiki.developers.facebook.com/index.php/FBJS/Examples/Ajax

    0 讨论(0)
提交回复
热议问题