After opening Firefox's scratchpad and inputting the following code...
function ajaxRequest()
{
var xmlhttp;
var domainName = location.host;
var url = 'http://leke.dyndns.org/cgi/dn2ipa/resolve-dns.py?domainName=';
url = url + domainName + '&x=' + Math.random(); // x= to avoid browser caching;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
alert(domainName+'='+xmlhttp.responseText);
}
}
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
ajaxRequest();
I am curious as to why my ajax code functions only within the same domain as the remote script (http://leke.dyndns.org), but fails in other domains like .
If it helps, here is the cgi script side...
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import os, cgi, cgitb, socket
cgitb.enable()
cgiData = cgi.FieldStorage() # Domain Name
domainName = cgiData.getvalue('domainName')
ipa = socket.gethostbyaddr(domainName)
sendIpa = ipa[2][0]
print 'Content-Type: text/html;charset=utf-8'
print ""
print sendIpa