sethi Posted January 11, 2010 Share Posted January 11, 2010 I am just trying to have two ajax requests spit out info from mysql entries every couple of seconds or so... the data to show is lightweight so nothing to worry about there. However, I have looked all the eff over for a difinitive explanation of a simple way to do asynchronys ajax calls that are timed, and just deliver... no interation required... This is the code i have... and i get nothing at all... when i had just one call(gm.php), it worked great. What in the heck am i doing wrong... thanksthanksthanks if you can help me. gm.js function getXMLHttp() { var xmlHttp try { //Firefox, Opera 8.0+, Safari xmlHttp = new XMLHttpRequest(); } catch(e) { //Internet Explorer try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert("Your browser does not support AJAX!") return false; } } } return xmlHttp; } function gm() { xml1 = getXMLHttp(); xml2 = getXMLHttp(); xml1.onreadystatechange = function() { if(xml1.readyState == 4) { handleResponse1(xml1.responseText); } } xml2.onreadystatechange = function() { if(xml2.readyState == 4) { handleResponse2(xml2.responseText); } } xml1.open('GET', 'gm.php', true); xml2.send(null); xml2.open('GET', 'status.php', true); xml1.send(null); setTimeout("gm()",6000); } function handleResponse1(response) { document.getElementById('rd').innerHTML = response; } function handleResponse2(response) { document.getElementById('status').innerHTML = response; } Quote Link to comment Share on other sites More sharing options...
dhvani Posted January 12, 2010 Share Posted January 12, 2010 Hi, First try this You have this in code xml1.open('GET', 'gm.php', true); xml2.send(null); xml2.open('GET', 'status.php', true); xml1.send(null); change it to xml1.open('GET', 'gm.php', true); xml1.send(null); xml2.open('GET', 'status.php', true); xml2.send(null); If this not works try to use two variables instead one xmlHttp. Hope this helps you out Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.