I am trying to get data from a server using JSONP
but I keep getting a warning in my console
Resource interpreted as Script but transferred with MIME type text/json:
Below is my ajax call
var loginData = {
"strUniqueID" : "123",
"UserName" : "UserName",
"Password" : "Password"
};
$.ajax({
url: http://domain.com,
type: "POST",
data: {'data':$.toJSON(loginData)},
contentType: "text/plain",
dataType: "jsonp",
jsonpCallback: 'jsonCallback',
success: function(data) {
console.log('Success');
console.log(data);
},
error: function(jqXmlHttpRequest, textStatus, errorThrown) {
// Display the error.
console.log('Error: ' + textStatus);
console.log('Error thrown: ' + errorThrown);
}
});
Because of the warning I am receiving I am also getting this error
Uncaught SyntaxError: Unexpected token :
In Firefox this shows up as
SyntaxError: missing ; before statement
Is this because my data isn't getting brought back in the correct format?
If I open the URL with the parameters I get the response correctly
{"response":"SESSION ID"}
But I also get an error from the ajax call
Error: parsererror
Error thrown: jsonCallback was not called
I've been racking my brains with this for a few hours now and I am stumped!