This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes ajax:callback function not called for every readystatechange of the request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "ajax:callback function not called for every readystatechange of the request" Watch "ajax:callback function not called for every readystatechange of the request" New topic
Author

ajax:callback function not called for every readystatechange of the request

K Hemanth
Greenhorn

Joined: Feb 18, 2006
Posts: 4
Hi
I am working with an ajax program.
In that i have defined a callback funtion
but that function is not being called for every readystatechange of the request object for the first request .
but it is working fine from the second request.

function find(start,number){
var nameField=document.getElementById("text1").value;
var starting=start;
var total=number;
if(form1.criteria[0].checked) {
http.open("GET", url + escape(nameField)+"¶m2="+escape("exact")+"¶m4="+escape(starting)+"¶m5="+escape(number));
}
else if(form1.criteria[2].checked) {
http.open("GET", url + escape(nameField)+"¶m2="+escape("prefix")+"¶m4="+escape(starting)+"¶m5="+escape(number));
}
http.onreadystatechange = callback2;
http.send(null);
}

function callback2(){
if (http.readyState == 4) {//request state
if(http.status==200){
var message=http.responseXML;
alert(http.responseText);
Parse2(message);
}else{
alert("response is not completed");
}
}else{
alert("request state is :-"+http.readyState);
}
}
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
how are you defing http and when you mean it is working for the second request, you talking if branch or calling it twice. If twice, how fast is the request apart?

Eric
 
 
subject: ajax:callback function not called for every readystatechange of the request
 
Similar Threads
Notify Users before session expires
AJAX Question
Problem with http request and external javascript
ajax:Callback function not being called for every readystate change for first request
xmlhttprequest is not sending any request to the servlet