sayedsohail Posted October 21, 2007 Share Posted October 21, 2007 Hi everyone, My xmlhttp function is sometimes not working properly, i mean with some ie browsers its showing error, xhr[null],. Can someone please correct my mistakes, please. thanks, Here is my code var xhr = new Array(); // ARRAY OF XML-HTTP REQUESTS var xi = new Array(0); // ARRAY OF XML-HTTP REQUEST INDEXES xi[0] = 1; // FIRST INDEX SET TO 1 MAKING IT AVAILABLE function xhrRequest() { // xhrsend IS THE xi POSITION THAT GETS PASSED BACK // INITIALIZED TO THE LENGTH OF THE ARRAY(LAST POSITION + 1) // IN CASE A FREE RESOURCE ISN'T FOUND IN THE LOOP var xhrsend = xi.length; // GO THROUGH AVAILABLE xi VALUES for (var i=0; i<xi.length; i++) { // IF IT'S 1 (AVAILABLE), ALLOCATE IT FOR USE AND BREAK if (xi[i] == 1) { xi[i] = 0; xhrsend = i; break; } } // SET TO 0 SINCE IT'S NOW ALLOCATED FOR USE xi[xhrsend] = 0; // SET UP THE REQUEST if (window.ActiveXObject) { var activeXObjects = ['Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP']; for(var p=0; p<activeXObjects.length; p++) { try{ xhr[xhrsend] = new ActiveXObject(activeXObjects[p]); } catch(err){} } } else if (window.XMLHttpRequest) { xhr[xhrsend] = new XMLHttpRequest(); } return (xhrsend); } // CALLING/CREATING XMLHTTP REQUEST. var xhri = xhrRequest(); xhr[xhri].open('GET', file + query_string), true); Quote Link to comment 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.