| | |
xmlhttp.readyState = 0 (why???)
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2007
Posts: 227
Reputation:
Solved Threads: 0
hi,
basically i have this function.
which calls this function to initialize xmlhttp
/******** i also have this function which is working *******/
Q: i am wondering if I have 2 functions calling the GetXmlHttpObject() function,,,, would that cause conflict or something? I really don't think it should.
Thanks for helping AJax newbie...
basically i have this function.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function showDetail(checkBoxShipmentId) { xmlhttp = GetXmlHttpObject(); // this calls function below if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; } var url="detailBackend.php"; url=url+"?shipmentid="+checkBoxShipmentId; //?shipmentid = value of the checkbox, which is the shipmentid url=url+"&ran="+Math.random(); if(xmlhttp.readyState ==4) { xmlhttp.onreadystatechange= displayDetail; xmlhttp.open("GET",url,true); xmlhttp.send(null); } else { status = xmlhttp.readyState; alert(status); ///// this always return 0 ///// } }
which calls this function to initialize xmlhttp
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; }
/******** i also have this function which is working *******/
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
var xmlhttp; function showShipment(shipmentIdFromDropDown) { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; } var url="responsexml.php"; url=url+"?q="+shipmentIdFromDropDown; url=url+"&ran="+Math.random(); //generate a random number and store to variable ran to make sure cookie or session don't make them all the same xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(null); }
Q: i am wondering if I have 2 functions calling the GetXmlHttpObject() function,,,, would that cause conflict or something? I really don't think it should.
Thanks for helping AJax newbie...
k2k,
The two calls to GetXmlHttpObject() will each cause an independent request objets to be returned and they should both work quite happily.
The only proviso is that if the two response handlers both affect the same js objects or the same areas of the DOM, then you could get "race effects", whereby two closely dispatched requests could respond in the reverse order and yield unexpected results.
However, in general this won't be an issue.
Airshow
The two calls to GetXmlHttpObject() will each cause an independent request objets to be returned and they should both work quite happily.
The only proviso is that if the two response handlers both affect the same js objects or the same areas of the DOM, then you could get "race effects", whereby two closely dispatched requests could respond in the reverse order and yield unexpected results.
However, in general this won't be an issue.
Airshow
50% of the solution lies in accurately describing the problem!
![]() |
Similar Threads
- using xmlHTTP.responseText in any other java function (JavaScript / DHTML / AJAX)
- alert(xmlHttp.responseText) not working (JavaScript / DHTML / AJAX)
- PHP Ajax Search (PHP)
- xmlHTTP respnse (JavaScript / DHTML / AJAX)
- Interpret HTTP (Content-Disposition) headers from an XMLHTTP object? (JavaScript / DHTML / AJAX)
- XMLHttpRequest, out of the FF frying pan, into the IE frying pan. (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Hidden input with JS + JSP
- Next Thread: Float DIV jumps in firefox
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
acid2 ajax ajaxexample ajaxjspservlets array autoplay blackjack browser captcha captchaformproblem cart child close codes date debugger decimal dependent design developer disablefirebug dom element embed engine enter events ext file firefox flash focus form forms frameworks game gears getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe java javascript javascripthelp2020 javascripts jquery jsp jump libcurl listbox maps marquee masterpage math media menu onerror onmouseoutdivproblem onmouseover onreadystatechange parameters paypal pdf php player position post programming prototype rated redirect safari scale scriptlets scroll search security size software solutions sources star starrating stretch synchronous toggle tweet unicode variables web webkit webservice window \n





