Two makeResquest run one into another not working with Explorer
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Friday, April 25, 2008 10:06 AM

Hello, I have a js function that calls a AJAX function. Then, if the return code is correct, another AJAX function is called. It works perfectly with Mozilla but I am having a problem with Explorer... the 2nd AJAX call is not performed!!! I have put an alarm after the command: http_request.open('GET', url, true); alert("AFTER OPEN"); http_request.send(null); WIth Mozilla the alarm is fired but not with EXPLORER. Could you tell me what is wrong please? It seems that if a http_request.open is done, a second one cannot be done. Here is part of the code. I don't know a lot about AJAX so I'm sure the solution wi   More>>

Hello,


I have a js function that calls a AJAX function. Then, if the return code is correct, another AJAX function is called. It works perfectly with Mozilla but I am having a problem with Explorer... the 2nd AJAX call is not performed!!!


I have put an alarm after the command:
http_request.open('GET', url, true);
alert("AFTER OPEN");
http_request.send(null);


WIth Mozilla the alarm is fired but not with EXPLORER.


Could you tell me what is wrong please?


It seems that if a http_request.open is done, a second one cannot be done.


Here is part of the code. I don't know a lot about AJAX so I'm sure the solution will be easy for you to find:

			
..
function add()
{
// Add the address
//-----------------------
target=1;
myRand=parseInt(Math.random()*99999999); // cache buster
var url="addVlr.jsp?rand="+myRand+"&vlrAddress="+new_vlr_address;
makeRequest(0,url);
}
...
function makeRequest(option,url)
{
http_request = false;

if (window.XMLHttpRequest) // Mozilla, Safari,...
{
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType)
{
http_request.overrideMimeType('text/xml');
}
}
else
{
if (window.ActiveXObject) // IE
{
try
{
http_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
}

if (!http_request)
{
alert('Giving up. Cannot connect.');
return false;
}
if (option == 0)
{
http_request.onreadystatechange = alertContents;
}
else
{
http_request.onreadystatechange = alertContents1;
}
http_request.open('GET', url, true);
alert("AFTER OPEN");
http_request.send(null);
}

function alertContents()
{
if (http_request.readyState == 4) // COMPLETE
{
if (http_request.status == 200)
{
var values = http_request.responseText;
ier=trim(values);
if (ier !=0)
{
alert(ier);
}
else
{
// Treatment goes here
....
if (target == 1)
{
// Add address to array and sort it
//---------------------------------
myRand=parseInt(Math.random()*99999999);
var vlr_list=document.forms[1].vlr.value;
var url="sortVlr.jsp?rand="+myRand+"&vlrList="+vlr_list+"&vlrAddress=
"+new_vlr_address;
document.forms[1].vlr_addr.value="";
makeRequest(1,url);
}
}
}
else
{
alert("Problem");
}
}
}
   <<Less
About | Sitemap | Contact