Reputation: 4006
I am making a jsonp ajax call to a local service which responds with a valid javascript response. The ajax request looks like below:
$.ajax({
url: "http://localhost:12345",
type: "GET",
dataType: "jsonp",
jsonpCallback: "myFunction",
cache: false,
success: function (data) {
console.log('success');
},
error: function (jqxhrInternal, message, errorThrown) {
console.log(JSON.stringify(jqxhrInternal));
console.log('message: ' + message);
console.log('errorThrown: ' + errorThrown);
}
});
And the response returned has a "application/javascript" Content-Type header with a value of:
myFunction({"key": "value"});
The script is added to the webpage automatically and the function is executed without any errors, however the ajax function is entering the error function and is telling me that myFunction
was not called. I've googled for hours and tried everything, jQuery just won't detect that the function has successfully executed. The jQuery version is 3.6.1. What is the reason for this behaviour from jQuery and how can I resolve it?
Upvotes: 0
Views: 34