Ajax sometimes stops at readystate 1

C

cypress phill

Hi,

I'm using ajax for ms-crm customizations for a customer. However i
can't seem to let it work consistently. Most op the time it just stops
at readystate 1.

when i save a record, a couple op WS should be executed. It executes
the webservice but i don't get to evaluate what it returned. Sometimes
it handles everything well and then the next time it just doesnt get to
readystate 4 (needed to get a result).

Is there some setting i can check or something else? What should be
enabled in IE?

here are my AJAX methods i call from within a javascript function:

function initAJAX (){
var Ajax = null;
// IE/Windows ActiveX version
if(window.ActiveXObject) {
try { Ajax = new ActiveXObject("Msxml2.XMLHTTP"); }
catch(e) {
try { Ajax = new ActiveXObject("Microsoft.XMLHTTP"); }
catch(e) { Ajax = null; }
}
}
// andere browsers
if(!Ajax && typeof XMLHttpRequest != "undefined") {
try { Ajax = new XMLHttpRequest();
} catch(e) { Ajax = null; }
}
return Ajax;
}

function remoteReq(url, postData, handler) {
var req = initAJAX ();
req.open("POST", url, true); // bij true (=asynchroon) moet je een
handler functie meegeven (onreadystatechange)
req.onreadystatechange = function (){
// only if req shows "loaded"
alert(req.readyState);
if (req.readyState == 4) { // 4: loaded
// only if no errors
if (req.status == 200) { // 200 : zonder fouten verlopen
handler(req);
//delete req;
}
else {
alert("AJAX Error : " + req.status + " : " + req.statusText);
}
}
}
req.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
req.send(postData);
}

Thanx a lot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,038
Messages
2,570,372
Members
47,018
Latest member
IrisN51866

Latest Threads

Top