How To Add Custom Header in Ajax Request for cross domain JsonP call

半世苍凉 提交于 2019-12-20 04:49:47

问题


Can any one tell me how to add custom header using ajax call in jquery for cross domain jsonp call.i am calling webservice in html page using ajax cross domain call.for that is use jsonp and now i have to send some parameter in header so how i set header.


回答1:


I am afraid that this is not possible. jQuery uses a <script> tag for JSONP and as you know, you cannot set custom headers with this tag. As a possible workaround you could write a server side script on your domain which will act as a bridge between your domain and the remote domain. Then send a normal AJAX request to your script which in turn will delegate the call to the actual web service. Since it is a server-to-server communication your script could set any HTTP request headers that are required by the remote service.



来源:https://stackoverflow.com/questions/13927610/how-to-add-custom-header-in-ajax-request-for-cross-domain-jsonp-call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!