How To Do Cross-domain Jsonp Request In Javascript
i'm working on a little sample of code but i'm getting some problem to do what i want. here is a sample of code. i found part of it on internet and tryed to use it. in the case jus
Solution 1:
You need to tell jQuery where to put the JSONP callback name.
Change the URL parameter to &method=?
.
Solution 2:
Here is a working example of jsonp cross domain
Is that what you are looking for?
If you have requested with query string
?callback=my_callback_method
then, your server must response data wrapped like this:
my_callback_method({your json serialized data});
see: Make cross-domain ajax JSONP request with jQuery
Hopefully this will work if your json is fine.
<!doctype html><html><head><title>JSONP example</title><scriptsrc="http://code.jquery.com/jquery-1.10.1.min.js"></script></head><body><h1>test jsonP</h1><script>var url = 'http://widget.mondialrelay.com//parcelshop-picker/v3_0/services/parcelshop-picker.svc/SearchPR?Brand=BDTEST%20%20&Country=FR&PostCode=62620&ColLivMod=24R&Weight=&NbResults=7&SearchDelay=&SearchFar=75&=Zone_Widget&VacationBefore=&VacationAfter=&Service=&Latitude=&Longitude=&method=jQuery16206304910685867071_1380876031038&_=1380879686732?callback=?';
$.ajax({
type: 'GET',
url: url,
async: false,
jsonpCallback: 'jQuery16206304910685867071_1380876031038',
contentType: "application/json",
dataType: 'jsonp',
success: function(json) {
console.dir(json.PRList);
},
error: function(e) {
console.log(e.message);
}
});
</script></body></html>
Post a Comment for "How To Do Cross-domain Jsonp Request In Javascript"