Jump to content

Recommended Posts

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 by sungpeng

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)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.