0

Im having an issue with the request below, for some reason I can seem to get the XML to display?

I've checked the URL and it displays fine, so im wondering whats going on?! Could anyone give me a hand? There should be something in the ResponseText not "NULL".

var url = "https://services.lexel.co.uk/paf/";

loadXMLDoc(url)

function loadXMLDoc(url)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET",url,false);
xmlhttp.send(null);
alert(xmlhttp.responseText);
}
1
  • Where'd you get this sample? It's wrong. Commented Feb 21, 2010 at 18:19

2 Answers 2

3

You cannot use AJAX to send a request to a different domain.

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

5 Comments

How can I use the XML post to get data from a different domain?
You need to write a server-side script on your domain that forwards the request to the other domain.
You can't. It's a XSS exploit possibility if it could. As SLaks said, use a server-side script.
What server-side language do you use?
@Josh the 3rd parameter of Send was "false" which means "Don't be asynchronous; block until we're done loading" [In other words, what he did is valid]
0

Here is some literature on cross-domain ajax: http://www.xul.fr/ajax/xdomainrequest.php Cross domain request (XDR) http://msdn.microsoft.com/en-us/library/dd573303(v=vs.85).aspx

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.