For all my friends who have a problem with PHP + JQuery + JSONP
here it is, I am using php 5.3 and jQuery 1.10
$('#button_submit2').click(function () {
prevent_caching = (new Date()).getTime();
$.ajax({
type: 'GET'
, url: "http://yoururl.com/webservice.php"
, dataType: 'jsonp'
, jsonp: 'callback'
, jsonpCallback: 'jsonp_reply'
, data: {
uniq_val: prevent_caching
, method_name: "get_all_tasks"
, format: 'jsonp'
}
, cache: false
, async: false
})
.success(function (rsp) {
console.log('success'+rsp);
})
.fail(function (xhr, error, thrownError) {
console.log('fail status:[' + xhr.status + '] error:[' + thrownError + ']');
})
.always(function () {
console.log('complete');
});
});
Talha source
share