Cross-Origin resource sharing and file://

前端 未结 2 815
面向向阳花
面向向阳花 2020-12-03 11:42

I am writing an HTML5 application that is gathering data from a few different sources using JSONP. Anything I\'m doing with a GET works perfectly. I\'m now trying to POST

2条回答
  •  情歌与酒
    2020-12-03 12:13

    As it would turn out, the easiest way to do this is to post to the target url inside of an iframe. Same origin policy on most browsers allows you to perform an HTTP POST from one domain to another unrelated domain. I solved the problem by adding an iframe to my page, initially set to a local bootstrapping page. Since that page was loaded from the same domain, I am able to control it via script. I used that to post the form to my target site, and polled the results to determine if my call was successful. It's not elegant, but it works.

提交回复
热议问题