[英]How do I retrieve and display html/asp/aspx page on different host using jQuery ajax?
I have an html page, which is a dynamically created asp/aspx page on http://host2.mydomain.com . 我有一个html页面,它是http://host2.mydomain.com上动态创建的asp / aspx页面。 I have no control over the html page. 我无法控制html页面。 I cannot modify it in any such way. 我无法以任何这种方式修改它。 I cannot modify this page; 我无法修改此页面; so, setting document.domain is out of the question, unfortunately. 因此,不幸的是,设置document.domain是不可能的。 This html page is compiled by a 3rd-party vendor and the code is close-source; 这个html页面是由第三方供应商编译的,代码是封闭源代码; I cannot view it or change it. 我无法查看或更改它。 I want to retrieve and display this page on http://host1.mydomain.com/page1.jsp using Ajax. 我想使用Ajax在http://host1.mydomain.com/page1.jsp上检索并显示此页面。
FYI: host1 is being served by IIS 7 and Apache Tomcat (for JSP pages). 仅供参考:IIS 7和Apache Tomcat(用于JSP页面)正在为host1提供服务。 And host2 is using IIS 7 and ASP. host2使用IIS 7和ASP。
How can I retrieve this page using a Ajax POST request? 如何使用Ajax POST请求检索此页面?
Thank you. 谢谢。
You can't with a standard AJAX call due to cross-domain policies, you would have to use JSONP or a form of JSONP http://en.wikipedia.org/wiki/JSONP 由于跨域策略,您无法使用标准的AJAX调用,因此必须使用JSONP或JSONP形式http://en.wikipedia.org/wiki/JSONP
Also, a common "gotcha" is that the cross-domain policies prevent secure to non-secure ajax as well. 同样,一个常见的“陷阱”是跨域策略也会阻止安全到不安全的ajax。 So a https://
page cannot request a http://
page and vice versa/ 因此, https://
页面无法请求http://
页面,反之亦然/
YQL
http://developer.yahoo.com/yql / YQL
http://developer.yahoo.com/yql/
and 和
JSON-P
http://en.wikipedia.org/wiki/JSONP JSON-P
http://en.wikipedia.org/wiki/JSONP
You are just going across subdomains so can do it using an iframe, look to this question - A question about cross-domain (subdomain) ajax request 您只是跨子域,所以可以使用iframe来完成此任务,请查看此问题- 有关跨域(子域)ajax请求的问题
The solution referenced: http://www.tomhoppe.com/index.php/2008/03/cross-sub-domain-javascript-ajax-iframe-etc/ 参考的解决方案: http : //www.tomhoppe.com/index.php/2008/03/cross-sub-domain-javascript-ajax-iframe-etc/
您编写服务器端脚本以检索页面内容,然后使用Ajax请求您的脚本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.