Запрос JSON, без установки таймаута
function ajax(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onreadystatechange = function(){
if (this.readyState == 4) {
if (this.status == 200)
callback(JSON.parse(this.responseText));
// иначе сетевая ошибка
}
};
xhr.send(null);
}
ajax('http://domain/script.php', function(data){
alert(JSON.stringify(data));
});