load a page using POST to iframe

邮差的信 提交于 2019-12-24 03:18: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:


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.



来源:https://stackoverflow.com/questions/10637382/load-a-page-using-post-to-iframe

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