Post data to JsonP

后端 未结 7 1332
傲寒
傲寒 2020-11-22 07:22

Is it possible to post data to JsonP? Or does all data have to be passed in the querystring as a GET request?

I have alot of data that I need to send to the service,

7条回答
  •  悲&欢浪女
    2020-11-22 08:02

    If you need to send a lot of data cross-domain. I usually create a service that you can call in two steps:

    1. First the client do a FORM submit (post allowed cross domain). The service stores the input in the session on the server (using the GUID as key). (the client creates a GUID and send's it as a part of the input)

    2. Then the client do a normal script-inject (JSONP) as a parameter you use the same GUID as you used in the FORM post. The service processes the input from the session and returns the data in the normal JSONP-fashion. After this the session is destroyed.

    This of course relies on that you write the server-backend.

提交回复
热议问题