Multiple AJAX-calls at the same time, dont get it to work

  • Zeroastic
  • Born
  • Born
  • No Avatar
  • Joined: Oct 11, 2008
  • Posts: 1
  • Status: Offline

Post October 11th, 2008, 9:57 am

Hi!

I'm trying to call multiple AJAX calls at the same time.

The problem is that only the latest call seems to update the page properly.
Any1 who could help me =>?

This is my code:

var xmlHttps, xmlHttps1, xmlHttps2, sTargetDiv, targeturl, getvar1;


function ajax(geturl,divtagg,get1,get2,get3,get4,get5)
{
xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)
{
alert ("Din webläsare stödjer inte ajax. Byt till IE 7.0, firefox,opera eller safari.");
return;
}

sTargetDiv=divtagg
targeturl=geturl
getvar1 = get1
var url=targeturl+"?get1="+get1+"&get2="+get2+"&get3="+get3+"&get4="+get4+"&get5="+get5+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
document.getElementById(sTargetDiv).innerHTML="<img src='loading.gif'>";
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}



function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById(sTargetDiv).innerHTML=xmlHttp.responseText
if(xmlHttp.responseText == "Bilden togs bort")
{
removeByID("image"+getvar1)
}
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;

try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}

return xmlHttp;
}

function ajaxPro(geturl1,divtagg1,geturl2,divtagg2)
{
ajax(geturl1,divtagg1,1);
ajax(geturl2,divtagg2,2);
}
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post October 11th, 2008, 9:57 am

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 175 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.