"jquery.jsonp.js" GET works. What about POST PUT DELETE OPTIONS? -
jsonp http methods besides (post, put, options, delete)
using jquery built-in $.ajax method looks this
$(document).ready(function() { $.ajax({ type: "get", url: "http://myurl.com/webservice&callback=?", ... }); only want draw attention line type: "get", $.ajax performing http put change type: "put",
this code example comes json parsing cross domain using jquery ajax
not using $.ajax
using google-code's jquery.jsonp https://github.com/jaubourg/jquery-jsonp
here example of using jquery.jsonp.js method
$.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"); } }); this works perfectly. how jsonp request not question.
in $.jsonp, perform other http methods: put post delete options ... ? $.jsonp support type="put",?
it's not mentioned @ in docs: api.md , tipsandtricks.md nor in source code.
update
@ohgodwhy there hack (iframes / proxy) post 2 work cross domains. using put/post/delete jsonp , jquery
@thefrontender linked article suggests looking into, "cross-origin resource sharing (cors)"
cors support browser http://caniuse.com/cors
same article says, "you encode json url parameter, shame on thinking that." in of history, shame never stopped anyone? simple, lazy, , in limited cases gets job done.
thx 4 everyones ...
json-p works injecting script tag document: not traditional xhr request.
so can perform requests. can not perform put requests.
more details in write-up: http://johnnywey.wordpress.com/2012/05/20/jsonp-how-does-it-work/
Comments
Post a Comment