Send Data To Remote Server With Jquery Ajax
I'm working on an app, that generates a javascript code, which displays a widget on a website. When a data is submitted through the widget form, it posts the data to the server wit
Solution 1:
Well, you can try this using JSONP
:
Live demo:http://jsfiddle.net/5CUk2/
(Please check browser console)
$(function() {
//Example using flickr APIvar diffDomainUrl = 'http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=mycallback&tags=monkey&tagmode=any&format=json';
$('#jsonpbtn').on('click', function() {
$.ajax({
url: diffDomainUrl,
dataType: 'jsonp',
data: {},
success: function (data, textStatus) {
console.log(textStatus);
console.log(data);
},
jsonpCallback: 'mycallback'
});
});
});
By the way, you can try other possible "ways" to make a cross-domain
request by taking a look to this, maybe can help:
Post a Comment for "Send Data To Remote Server With Jquery Ajax"