Need help reading XML using the browsers XMLHttpRequest object and client side JavaScript request
Can someone help me solve the following problem. For the URL listed, assume that if you did go to that URL, then the XML will be displayed in the web page, and it will look like the XML displayed in the "Code:" section of this post.
1. Create an HTML page with three <div>s and a button.
2.Upon clicking the button then using client-side JavaScript requests, get the XML returned from the URL: http://www.myrul.com/result.ashx
using the browsers XMLHttpRequest object.
3.From the XML returned from the JavaScript request, display the EventTime
and the Sport for the Sport with the latest post time in the three <div>s
created in the first step.
I appreciate your help. I noticed it was not working and so I traced into the code in the debugger. I get an "Access Denied" message when this line of code is executed:
self.xmlHttpReq.open('POST', strURL, true);
That line of code is inside of the function xmlhttpPost(strURL, strQueryString)
Do you have any idea why I am getting that message?
Pieter Marais
AJAX has this built-in security functionality that prevents you from making requests to a domain other than that on which it is hosted. So if this script, for example, is hosted on www.myajax.com, you can't go and make requests to www.wireless.org. Hence the "Access Denied" message.
If you want to use this script, the file or script that you wish to access with the AJAX must be on the same domain.
There are workarounds though, depending on which system you are using the AJAX. For example, if your system supports PERL, you can use a script that implements the HTTP::Request and LWP::UserAgent modules.
So instead of calling the URL directly, you can use a script on your server that retrieves the information for you for the other domain and then returns it to the AJAX on your domain.
self.xmlHttpReq.open('POST
That line of code is inside of the function xmlhttpPost(strURL, strQueryString)
Do you have any idea why I am getting that message?