473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

[XMLHttpRequest] - onreadystatechange work in IE nothin in mozilla

hello,

I'm writing a program using XMLHttpRequest that works in the main case
on IE and mozilla but this code works only on IE ... why ?

probleme is located at mark 'HERE' at the end of code.

{__start_of_code__} ('piece' of code)

....
// OBJ. HTTP
function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}

<!-- OBJETS HTTP -->
var http = getHTTPObject();
var http1 = getHTTPObject();
var http2 = getHTTPObject();

// GESTION EVENT AJAX
function handleHttpResponse(varhttp,context){
switch (varhttp.readyState){
case 4:
switch (context){
case 'search':
...
break ;
case 'addline':
var sbar = document.getElementById("sbar") ;
sbar.innerHTML += varhttp.responseText ;
pbar1.next() ;
break ;
case 'ping':
...
break ;
default:
alert("!! ERROR !!") ;
break ;
}
break ;
case 3:
logger("Status : Transfert de donnees en cours...") ;
break ;
case 2:
logger("Status : Attente de la reponse...") ;
break ;
case 1:
logger("Status : Connexion au serveur...") ;
break ;
case 0:
logger("Status : Connexion non initialise !! ") ;
break ;
}
}
function wake(cnt){

var url_base =
document.getElementById("machinelist").getElements ByTagName("a")[cnt] ;
var url_sbar = new String(url_base) ;

if (url_base) {

url_sbar = url_sbar.replace("index.php","proc.php");
url_sbar = url_sbar.replace("wakeup","ajaxbehav_sbar");

// JS SYNCHRONE !!
http1.open("GET", url_sbar,false) ;
// HERE !!!!!
// this line has no effect ; state never change !!!
http1.onreadystatechange=function(){handleHttpResp onse(http1,"addline")}
;
///////////////////////////////////////////////
http1.send(null) ;

http2.open("GET", url_base,false);
http2.send(null) ;
//====================================

}

}
....
{__end__}

how this code return no error in any browser but works only on IE ??

thanks.

regards.

Aug 29 '06 #1
2 6172


jh****@gmail.com wrote:

// JS SYNCHRONE !!
http1.open("GET", url_sbar,false) ;
// HERE !!!!!
// this line has no effect ; state never change !!!
http1.onreadystatechange=function(){handleHttpResp onse(http1,"addline")}
;
///////////////////////////////////////////////
http1.send(null) ;
If you make a synchronous request then the send() call blocks your
script until the response is there and you don't need an
onreadystatechange event handler but you should simply have your code
check the status, responseText and so on directly here after the send
call. Firefox does not fire onreadystatechange for the synchronous call.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 29 '06 #2

it's OK ;) - that works

thanks...

Martin Honnen wrote:
jh****@gmail.com wrote:

// JS SYNCHRONE !!
http1.open("GET", url_sbar,false) ;
// HERE !!!!!
// this line has no effect ; state never change !!!
http1.onreadystatechange=function(){handleHttpResp onse(http1,"addline")}
;
///////////////////////////////////////////////
http1.send(null) ;

If you make a synchronous request then the send() call blocks your
script until the response is there and you don't need an
onreadystatechange event handler but you should simply have your code
check the status, responseText and so on directly here after the send
call. Firefox does not fire onreadystatechange for the synchronous call.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 30 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jarson | last post by:
My JavaScript is trying to POST data to a CGI script (Perl) using XMLHttpRequest. My CGI server gets different data from IE than Mozilla Firefox. // For Mozilla, req = new XMLHttpRequest(); //...
12
by: knocte | last post by:
Hello. I have always thought that the eval() function was very flexible and useful. If I use it, I can define functions at runtime!! However, I have found a case where eval() does not work...
7
by: SE | last post by:
Hi all, Apologies if this has been done before. I am trying to do some stuff with XMLHttpRequest in mozilla but no dice. I have finally pared everything down to the minimum to see what is...
6
by: Nathan | last post by:
Can I run two XMLHTTPRequest objects at the same time? Im able to get one to work without problems. If I put a call to a function inside the first ones onreadystatechange function, the 2nd ones...
3
by: keith.schincke | last post by:
I know I must be missing something basic. I am developing of Firefox 1.5 and am trying to to send a basic QUERY_STRING to a test CGI that will print the data back to the brower: I can print my...
2
by: petermichaux | last post by:
Hi, I thought it is about time I tried writing some JavaScript with XMLHttpRequest instead of just using the Yahoo! UI library. The simple page below works in both Safari and Opera but I don't...
13
by: TLaufenberg | last post by:
I'm new to Javascript programming and I've run into a bit of a snag with making an XMLHttpRequest in the Safari browser. Actually, the request doesn't work in Firefox either but only when I use a...
1
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.