PDA

View Full Version : How to access cross domain using JSON ajax



hannahwill
05-08-2009, 12:50 PM
hello

Question:

i get "Access denied" error.Can anyone convert the code below in JSON i need to

access data from some other domain. OR any other fully explained efficient method to access

cross domains plz.

---------js file--------------


window.onload=makeRequest;

function makeRequest()
{
var http_request={};
if (window.XMLHttpRequest)
{ // Mozilla, Safari,...
http_request = new XMLHttpRequest();
}
else
{
http_request=new ActiveXObject("Msxml2.XMLHTTP");
}

http_request.open("GET", "http://www.uclocal.com/LX-U.aspx?", false);
http_request.onreadystatechange=function()
{
if(http_request.readyState==3)
{
alert("data is loading...please wait");
}
else
if(http_request.readyState==4)
{
if(http_request.status==200)
{
document.write(http_request.responseText);
}
}
}
http_request.send();
}

codeexploiter
05-09-2009, 07:12 AM
By default ajax does not allow cross-domain access.