load a page using POST to iframe

2019-07-17 23:26发布

I want to create an iframe with other page visible inside. The page is outside my domain. Normally I do it like that:

$('<iframe />').attr('src','www.thepage.com?data=1').appendTo('body')

But if www.thepage.com is accessible via POST instead of GET, how should I load it? $.ajax( type:'POST',...) fails due to Origin null is not allowed by Access-Control-Allow-Origin.

1条回答
smile是对你的礼貌
2楼-- · 2019-07-17 23:51

Load in a temporary page that contains a form with the fields you need (hidden) and use Javascript to submit the form.

This happens to be a previous question that I asked. Response.Redirect with POST instead of Get?

Look at the answer from Pavlo. You can see how he's creating an html page with a form that does a submit on load of the body.

查看更多
登录 后发表回答