Skip to content

Instantly share code, notes, and snippets.

@jhjguxin
Created August 14, 2012 07:06
Show Gist options
  • Save jhjguxin/3347095 to your computer and use it in GitHub Desktop.
Save jhjguxin/3347095 to your computer and use it in GitHub Desktop.
AJAX Cross Domain Call - OK 200 but still getting Firebug / JQuery.js error

I trying to make a call to an external domain using $.ajax() and it WORKS, the server receives the call, but the response in firebug errors out in jquery.js line 7760. I've been beating my head at this all day and don't feel like I've made it much further.

I suspect it has something to do with the dataType or type of the request. But I've tried all kinds of things from POST to GET to JSONP in the type. For dataType, I've also tried "html", "text", "xml", "json", and even some combos of "text html" but no success.

cross-domain requests are only allowed for dataTypes "script" and "jsonp".

If your request is either of those, add the proper dataType option:

dataType: "jsonp" or dataType: "script"

$.ajax({
type: "POST",
url: "http://bbtang.com/knowledges",
dataType: "script",
success: function(result) {
console.log("SUCCESS");
console.log(result);
},
error: function(result) {
console.log("ERROR");
console.log(result);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment