I want to take some json from server but I have Error:
Error: jQuery111106328444090202681_1494341431062 was not called
at Function.error (file:///C:/Users/adm/Documents/temp/WP/wp/www/jquery/jquery-1.11.1.min.js:2:1809)
at h.jsonp.b.dataTypes.(anonymous function).b.converters.script json (file:///C:/Users/adm/Documents/temp/WP/wp/www/jquery/jquery-1.11.1.min.js:4:27648)
at Pc (file:///C:/Users/adm/Documents/temp/WP/wp/www/jquery/jquery-1.11.1.min.js:4:18120)
at x (file:///C:/Users/adm/Documents/temp/WP/wp/www/jquery/jquery-1.11.1.min.js:4:21525)
at HTMLScriptElement.b.onload.b.onreadystatechange (file:///C:/Users/adm/Documents/temp/WP/wp/www/jquery/jquery-1.11.1.min.js:4:26934)
I use jQuery 1.11.1 for jQuery mobile It's my js code:
function myRequest() {
$.ajax({
url: "http://dev.agro.ws/result.json",
dataType: 'jsonp',
crossDomain: true,
error: function(xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(thrownError);
},
success: function(data) {
console.log(data);
}
});
}
$(document).on("pageinit", "#main", function() {
$('#btnDownload').click(function(event) {
myRequest();
});
});
Can someone help with my problem?
As mentioned in a comment, the server you are querying in your $.ajax
request is returning the result in JSON format instead of JSONP. Take a look at the difference between JSON and JSONP Here . Here is a basic example in pseudocode (PHP) to check if the request is in fact JSONP
$callback = (isset($_GET['callback']) ? $_GET['callback'] : null);
if (isset($callback))
echo $callback . '([JSON HERE])';
else
echo '[JSON HERE]';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.