Answer the question
In order to leave comments, you need to log in
How to fix error on ajax request using jsonp?
I'm trying to get json from a third-party site ... but it gives an error, although I see in the console that I received json.
Generally ajax request is
jQuery.ajax({
url: 'https://www.oplata.info/asp2/price_options.asp',
type: 'GET',
dataType: 'jsonp',
data: {'p': id, 'n': 1, 'c': 'WMR'},
success: function(data) {
$('#cena').html(data.price);
}
});
jQuery.ajax({
url: 'https://www.oplata.info/asp2/price_options.asp',
type: 'GET',
dataType: 'json',
data: {'p': id, 'n': 1, 'c': 'WMR'},
crossDomain: true,
success: function(data) {
$('#cena').html(data.price);
}
});
Answer the question
In order to leave comments, you need to log in
in response to a jsonp request, non-json data should be returned, read how jsonp works
(well, more precisely, not just json)
https://ru.wikipedia.org/wiki/JSONP
you need to either correctly implement jsonp (checking for the get callback parameter)
or add on the server when sending data the header Access-Control-Allow-Origin
habrahabr.ru/post/114432
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question