JSONP: Is a callback necessary?

后端 未结 4 416
说谎
说谎 2021-01-21 17:08

I\'m creating an iOS / Droid app using AJAX, jQuery, and Phonegap. The backend is a Drupal 7 site serving content via web services. I\'m a little confused about the necessity fo

4条回答
  •  隐瞒了意图╮
    2021-01-21 17:30

    A JSONP call doesn't work without a callback. The data is loaded in a script tag, and if the code is not in a form of a method call, the result would just be an object that was discarded, and the success callback method would never be called.

    The ajax method is adding a callback parameter to the URL even if you don't specify one.

    In the documentation, under the "jsonp" value for the dataType setting:

    "Adds an extra "?callback=?" to the end of your URL to specify the callback."

    http://api.jquery.com/jQuery.ajax/

提交回复
热议问题