sungpeng Posted December 4, 2012 Share Posted December 4, 2012 (edited) function Ajax(){var xmlHttp; try{ xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari } catch (e){ try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer } catch (e){ try{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ alert("No AJAX!?"); return false; } } } xmlHttp.onreadystatechange=function(){ if(xmlHttp.readyState==4){ document.getElementById('innerscroll3').innerHTML=xmlHttp.responseText; } } xmlHttp.open("GET","http://www.domain.org/chat3.php", true); xmlHttp.send(null); } </script> <br> <div id="innerscroll3"></div> function Ajaxa(){ var xmlHttp; try{ xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari } catch (e){ try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer } catch (e){ try{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ alert("No AJAX!?"); return false; } } } xmlHttp.onreadystatechange=function(){ if(xmlHttp.readyState==4){ document.getElementById('innerfetch').innerHTML=xmlHttp.responseText; } } xmlHttp.open("GET","http://www.domain.org/chat4.php",true); xmlHttp.send(null); } </script> <div id="innerfetch"></div> I have two ajax scripts on the same page. I got a result that only one is loaded and the other is not. How do i get two ajax to load on the same page ? Edited December 4, 2012 by sungpeng Quote Link to comment https://forums.phpfreaks.com/topic/271588-how-do-i-get-two-ajax-to-load-on-the-same-page/ Share on other sites More sharing options...
jazzman1 Posted December 6, 2012 Share Posted December 6, 2012 Why the name of second function is called - Ajaxa, did you see that? Just create only one function that will have one parameter to get different values comming from GET. Just follow the rule of DRY principle ( Don't Repeat Yourself) Quote Link to comment https://forums.phpfreaks.com/topic/271588-how-do-i-get-two-ajax-to-load-on-the-same-page/#findComment-1397863 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.