I must be missing something here, because this seems like a very simple problem, but I've tried most of the solutions and haven't had any luck.
I am simply trying to create an ajax request cross-domain and store the result into a javascrip variable. I'm getting valid javascript, my callback is being fired, but my success never is.
I've tried:
Setting jsonp: false
with jsonpCallback: myCallback
(as it stands now, below)
Remobing jsonp: false
and jsonpCallback: mcCallback
and setting the url url?callback=?
A few other things... point being, I'm doing something wrong and it's pretty basic
For the example below, I do get the alert('hello')
but then I get parsererror
in the console (coming from the error function)
Edit to add how it is now after reading a comment. Same issue, though. Sucess is not called
$.ajax({
url: 'http://localhost/faqservice/questions',
type: 'GET',
dataType: 'jsonp',
error: function (x, t, r) { alert(x + t + r); },
success: function (data) {
alert('success');
}
});
How the question was originally
$(document).ready(function () {
$.ajax({
type: "GET",
url: "http://localhost/faqservice/questions",
dataType: 'jsonp',
jsonp: false,
jsonpCallback: myCallback,
error: function (httpReq, status, exception) {
console.log(status);
},
success: function(data) {
alert('success');
}
});
});
myCallback = function (data) {
alert('hello');
}