0

I have an html page, which is a dynamically created asp/aspx page on http://host2.mydomain.com. I have no control over the html page. I cannot modify it in any such way. I cannot modify this page; so, setting document.domain is out of the question, unfortunately. This html page is compiled by a 3rd-party vendor and the code is close-source; I cannot view it or change it. I want to retrieve and display this page on http://host1.mydomain.com/page1.jsp using Ajax.

FYI: host1 is being served by IIS 7 and Apache Tomcat (for JSP pages). And host2 is using IIS 7 and ASP.

How can I retrieve this page using a Ajax POST request?

Thank you.

5 Answers 5

1

YQL http://developer.yahoo.com/yql/
and
JSON-Phttp://en.wikipedia.org/wiki/JSONP

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you for your suggestion. Will these methods work, even though I have no control over the html page on host2.mydomain.com and it was not designed to encode/decode JSONP?
use YQL. It return complete html of the requested page
Thank you. What about JSONP? I thought JSONP is only useful if the page being requested is aware that it must encode JSONP. Is that correct?
JSON or JSON-P is used when server return data in JSON format. JSON-P is used to ByPass the same origin policy.
1

By setting proper CORS headers if you are using modern browsers. Have a look here

Comments

1

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

The solution referenced: http://www.tomhoppe.com/index.php/2008/03/cross-sub-domain-javascript-ajax-iframe-etc/

3 Comments

Thank you for your help. This would be a great solution if I could modify both pages; however, as I said in the question, I don't have access to the html page.
Could you just not use ajax and rather include the first page as an iframe on the second page?
I could but the issue I'm having with that is out of the scope of the question I posed. Thank you for your suggestion, though.
1

you write a server-side script to retrieve the page contents, then you use Ajax to request your script

3 Comments

Thank you very much for your suggestion. How can this be done, though? One box is IIS/Tomcat and the other is IIS/ASP. How can I write a Java/JSP script which will talk to the IIS/ASP box and retrieve it's dynamically created html page. I would need at least need some sort of web service which hands off requests from each box.
Hi, sorry I'm afraid I can't help you! I am a PHP developer, I have not clue how to do it otherwise
Yeah, PHP is my forte, as well. I prefer it. Thank you though for your help.
1

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

Also, a common "gotcha" is that the cross-domain policies prevent secure to non-secure ajax as well. So a https:// page cannot request a http:// page and vice versa/

1 Comment

Thank you very much for your help. Unfortunately, JSONP is not an option for me since I cannot edit the html page from the ASP side. (complicating matters is one host is JSP and the other is ASP).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.