0

After reading JSONP Explained I still have some questions.

1) What happens if you don't supply a callback function name, you just supply ?callback=? ?

2) What happens if you supply a callback function name, but you don't have a function with the same name declared in your code ?

Thanks

Community
  • 1
  • 1
Alon
  • 3,734
  • 10
  • 45
  • 64

2 Answers2

1

1.) That's actually up to the server handling the request.

2.) You get an "Uncaught ReferenceError" in your browser. That is the same as this snippet for example:

// b nowhere defined!
b();
ComFreek
  • 29,044
  • 18
  • 104
  • 156
0

jQuery will replace ? char with a callback function name. That name must be the function name in response to make jsonp request working.

$.getJSON('url/?callback=?').success(function(response){
    // Process response data;
});

Wil call e.g.

http://url/?callback=jQuery325412324_2343224

Then your server need to send back a callback like

jQuery325412324_2343224(['JSON_DATA'])
Bernhard
  • 4,855
  • 5
  • 39
  • 70