English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

As you know that ajax is asynchronous (happening at different times), that means say if i have two functions called in a sequence, one is for the ajax - goes to the server and fetches the data, and second one is to refresh the targetDiv to display the result, but the problem is that, if the internet is slow, the first one waits for the reponse from the server while the otherone refreshes the page even though the response is not received. and when the response is received, the targetDiv is not refreshed.

How can i call functions in sequence, say call a function or functions after the response is received.

2006-08-21 02:01:43 · 3 answers · asked by Manish 5 in Computers & Internet Programming & Design

3 answers

Are you using the XMLHttpRequest object? It provides functionality that does just what you want. You should be using an onreadystatechange event to trigger the function that fills the target div, not just calling them directly in sequence.

2006-08-21 02:17:04 · answer #1 · answered by Drew 6 · 1 0

relies upon on the context. Ajax in Greek delusion replace into between the major severe warriors on the Greek section interior the Trojan conflict. Ajax in football is likely going one among the major typically used ecu communities, depending in Amsterdam, Netherlands. Ajax in software Programming stands for Asynchronous JavaScript and XML, a fashion for optimizing the way a cyber web website is rendered onto the browser. Ajax is likewise an commercial air purifier from Colgate-Palmolive.

2016-11-26 21:12:28 · answer #2 · answered by ? 4 · 0 0

I agree with Drew,

(this is a pretty rough example but demonstrats the point)

function ajax(paramaters) {
// Mozilla version
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
}
// IE version
else if (window.ActiveXObject) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
xhr.open("POST","myPage.php");
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xhr.send(paramaters);

// THE onreadystatechange FUNCTION

xhr.onreadystatechange= function() {
if (xhr.readyState==4) {
alert("I'm done loading");
document. getElementByID("Div") .innerHTML = xhr.responseText;
}
}


}

2006-08-21 02:38:37 · answer #3 · answered by Anonymous · 1 0

fedest.com, questions and answers