Ho un problema con JSON: non riesco ad acquisire dati da un servizio esterno.
Mi spiego meglio.
Il codice utilizzato è il seguente:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JSON</title>

<script type="text/javascript" src="json.js"></script>
<script type="text/javascript">

var xmlHttp;
var url;

function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}

function doJSON() {

url = "ws.geonames.org/postalCodeSearchJSON?placename=Roma&maxRows=1";
//url = "index.html";

createXMLHttpRequest();
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.send(null);
}

function handleStateChange() {
if(xmlHttp.readyState == 4) {
alert(url);

if(xmlHttp.status == 404) {
alert("L'URL non esiste");
}

if(xmlHttp.status == 200) {
parseResults();
}
}
}

function parseResults() {
var responseDiv = document.getElementById("rispostaServer");
if(responseDiv.hasChildNodes()) {
responseDiv.removeChild(responseDiv.childNodes[0]);
}

var responseText = document.createTextNode(xmlHttp.responseText);
responseDiv.appendChild(responseText);
}


</script>
</head>

<body onload="doJSON();">

<h2>Risposta Server:</h2>

<div id="rispostaServer"></div>

</body></html>

Se utilizzo il primo valore della variabile "url" (geonames) ottengo un errore 404 e quindi compare l'alert "L'URL non esiste" ma, da come potrete vedere digitando l'indirizzo nel browser, l'url esiste eccome (e restituisce il risultato richiesto in formato JSON)!!
Tuttavia se assegno "index.html" alla variabile "url" non ho alcun problema.
Ho provato anche il il webservice di yahoo ma non funziona lo stesso.
Il problema dovrebbe essere quindi nell' XMLHttpRequest.
Cosa sbaglio e come posso risolvere?

Grazie.

P.S.: il file json.js è quello standard ma comunque in questa pagina non viene utilizzato.