2

What does this (highlighted in bold) stand for in getJSON

$.getJSON('http://www.example.com/test.php?**callback=?**',...)

The =? in callback=? is what got me confused, because I thought it basically meant "go to the url provided and find the instances where a callback is issued".

The reason why I'm asking is what happens if I do this:

$.getJSON('http://www.example.com/test.php?**callback=hey**',...)

Does it look for a function in the test.php that is called hey with a jsonp callback or does the result of the callback got to a function in the script called hey?

I'm kind of lost.

4

1 回答 1

4

It means the request is being treated as JSONP.

From the jQuery documentation:

JSONP

If the URL includes the string "callback=?" (or similar, as defined by the server-side API), the request is treated as JSONP instead. See the discussion of the jsonp data type in $.ajax() for more details.

于 2013-07-05T23:40:58.137 回答