Note that there are some explanatory texts on larger screens.

plurals
  1. PO"jquery.jsonp.js" GET works. What about POST PUT DELETE OPTIONS?
    text
    copied!<h1>jsonp http methods besides GET (POST, PUT, OPTIONS, DELETE)</h1> <p>Using jquery built-in $.ajax method looks like this</p> <pre><code>$(document).ready(function() { $.ajax({ type: "GET", url: "http://myurl.com/webservice&amp;callback=?", ... }); </code></pre> <p>Only want to draw attention to the line <code>type: "GET",</code> With $.ajax performing a http PUT would be simply change <code>type: "PUT",</code></p> <p>This code example comes from <a href="https://stackoverflow.com/questions/14868463/json-parsing-from-cross-domain-using-jquery-ajax">JSON parsing from cross domain using jquery ajax</a></p> <h1>Not using $.ajax</h1> <p>Using google-code's jquery.jsonp <a href="https://github.com/jaubourg/jquery-jsonp" rel="nofollow noreferrer">https://github.com/jaubourg/jquery-jsonp</a></p> <p>Here is an example of using jquery.jsonp.js with the GET method</p> <pre><code>$.jsonp({ cache: false, url: 'http://www.mydomain.com/logicalurl/2/', callbackParameter: 'callback', timeout: 10000, success: function(json, textStatus, xOptions) { myglob = json; MyModulePatternObject.initNew(json); }, error: function (xOptions, textStatus) { console.log("fail"); } }); </code></pre> <p>This works perfectly. How to do a GET jsonp request is not my question.</p> <p>In $.jsonp, would like to perform the other http methods: PUT POST DELETE OPTIONS ... ? Does $.jsonp support the <code>type="PUT",</code>?</p> <p>It's not mentioned at all in the docs: API.md and TipsAndTricks.md Nor in the source code. </p> <h1>UPDATE</h1> <p>@ohgodwhy There is a hack (iframes / Proxy) to get POST 2 work cross domains. <a href="https://stackoverflow.com/questions/5345493/using-put-post-delete-with-jsonp-and-jquery">Using PUT/POST/DELETE with JSONP and jQuery</a></p> <p>@thefrontender Linked article suggests looking into, "Cross-Origin Resource Sharing (CORS)"</p> <p>CORS support by browser <a href="http://caniuse.com/cors" rel="nofollow noreferrer">http://caniuse.com/cors</a></p> <p>Same article also says, "You could encode JSON as a URL parameter, but shame on you for even thinking that." In all of history, shame never stopped anyone? Simple, lazy, and in limited cases gets the job done.</p> <p>Thx 4 everyones help ...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload