-
Notifications
You must be signed in to change notification settings - Fork 264
jsonp is called instead of json in cross domain requests #329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
If you are trying to post a data. you could not do it So, You Can use get method in regards with the cross domain, Trying using crossdomain:true, in your ajax call |
The jsonp request in question happens on my site for example here http://www.redditp.com/r/qwer/awwasdfasdfasdfa/ note that I do give an error after a timeout though the 404 arrives before the alert pops up. Will crossdomain:true help me catch and handle the 404 event? |
U can Very handle the 404 Event. |
So long as you are in here, could you separate each of those Also, have you signed the CLA? http://contribute.jquery.org/CLA/ |
Fixed that and just signed. I'll verify the 404's catchable with crossdomain:true hopefully in ~10 hours. |
I think this is too vague/incomplete, and I'm not quite sure how to fix it. In which cases does it force a "jsonp request"? Did you verify the catchable 404s? You can make an xhr post or get using CORS and it won't try to use jsonp. You would need to set the xhrFields: {
withCredentials: true
} |
<li>"json": Evaluates the response as JSON and returns a JavaScript object. Cross-domain requests may invoke "jsonp" unless explicitly "jsonp" is set to false.. The JSON data is parsed in a strict manner; any malformed JSON is rejected and a parse error is thrown. As of jQuery 1.9, an empty response is also rejected; the server should return a response of <code>null</code> or <code>{}</code> instead. (See <a href="http://json.org/">json.org</a> for more information on proper JSON formatting.)</li> | ||
<li>"jsonp": Loads in a JSON block using <a href="http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/">JSONP</a>. Adds an extra "?callback=?" to the end of your URL to specify the callback. Disables caching by appending a query string parameter, "_=[TIMESTAMP]", to the URL unless the <code>cache</code> option is set to <code>true</code>.</li> | ||
<li>"text": A plain text string.</li><li>multiple, space-separated values: <strong>As of jQuery 1.5</strong>, jQuery can convert a dataType from what it received in the Content-Type header to what you require. For example, if you want a text response to be treated as XML, use "text xml" for the dataType. You can also make a JSONP request, have it received as text, and interpreted by jQuery as XML: "jsonp text xml." Similarly, a shorthand string such as "jsonp xml" will first attempt to convert from jsonp to xml, and, failing that, convert from jsonp to text, and then from text to xml. | ||
</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be on the previous line.
@ubershmekel - do you have any updates on this issue specifically for @kswedberg's comment? It seems like one of those awkward edge cases we don't want to document unless we can clearly explain the situation it occurs in. |
@ubershmekel This PR needs some updates. See comments above. It would be nice if you could do them? |
Fixed the complaints and fixed the merge. From my testing |
Thanks @ubershmekel. What do we think @gnarf @kswedberg? |
I definitely like this formatting better. For this:
I'd change it to something like:
|
ping @ubershmekel |
Sorry guys, I was abroad for a few weeks. It's a bit of a pain that every time I come back to this tiny change the pull request has merge conflicts. I do like the proposed wording. If I fix it per @dmethvin would that be the final iteration? |
For now feel free to not care about merge conflicts. I can take care of them while merging. |
Relevant li's have newlines between them now.
Rebased with the new wording. |
Whoa, sorry this got buried. LGTM! |
<ul><li>"xml": Returns a XML document that can be processed via jQuery.</li><li>"html": Returns HTML as plain text; included script tags are evaluated when inserted in the DOM.</li><li>"script": Evaluates the response as JavaScript and returns it as plain text. Disables caching by appending a query string parameter, "_=[TIMESTAMP]", to the URL unless the <code>cache</code> option is set to <code>true</code>. <strong>Note:</strong> This will turn POSTs into GETs for remote-domain requests. </li><li>"json": Evaluates the response as JSON and returns a JavaScript object. The JSON data is parsed in a strict manner; any malformed JSON is rejected and a parse error is thrown. As of jQuery 1.9, an empty response is also rejected; the server should return a response of <code>null</code> or <code>{}</code> instead. (See <a href="http://json.org/">json.org</a> for more information on proper JSON formatting.)</li><li>"jsonp": Loads in a JSON block using <a href="http://bob.ippoli.to/archives/2005/12/05/remote-json-jsonp/">JSONP</a>. Adds an extra "?callback=?" to the end of your URL to specify the callback. Disables caching by appending a query string parameter, "_=[TIMESTAMP]", to the URL unless the <code>cache</code> option is set to <code>true</code>.</li><li>"text": A plain text string.</li><li>multiple, space-separated values: <strong>As of jQuery 1.5</strong>, jQuery can convert a dataType from what it received in the Content-Type header to what you require. For example, if you want a text response to be treated as XML, use "text xml" for the dataType. You can also make a JSONP request, have it received as text, and interpreted by jQuery as XML: "jsonp text xml." Similarly, a shorthand string such as "jsonp xml" will first attempt to convert from jsonp to xml, and, failing that, convert from jsonp to text, and then from text to xml. | ||
</li></ul> | ||
<ul> | ||
<li>"xml": Returns a XML document that can be processed via jQuery.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"xml"
I wonder if these shouldn't be in <code>
elements. For the rest this LGTM!
I'm going to make that trivial change myself and land this one. Thanks for your hard work, @ubershmekel, and sorry for it taking too long :) |
This was surprising to me and I'm still not sure how to handle cross-domain jsonp 404 responses.