Liquid Fire Posted May 10, 2007 Share Posted May 10, 2007 when i do: <select name="destination_code" onchange="AJAXRequest('/_assets/ajax/revenue_options.php','get=tour_code&destination_code=' + this.value, 'tour_code_list');"> this run the AJAXRequest function just fine but when i do: <select name="destination_code" onchange="AJAXRequest('/_assets/ajax/revenue_options.php','get=tour_code&destination_code=' + this.value, 'tour_code_list'); AJAXRequest('/_assets/ajax/revenue_options.php','get=hotel&destination_code=' + this.value, 'hotel_list');"> I am getting this wierd jacascript error: Error: uncaught exception: [Exception... "Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIXMLHttpRequest.send]" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: http://netres.studentcity.com/_assets/javascripts/ajax_library.js :: AJAXRequest :: line 32" data: no] here is the javscript file for my AJAXRequest stuff: function CreateXMLHttpRequestObject() { var test = null; if(window.XMLHttpRequest) { return new XMLHttpRequest(); } else if(window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); } } var xml_http_request_object = CreateXMLHttpRequestObject(); var output_id = null; function AJAXRequest(passed_url, url_variables, passed_output_id) { output_id = passed_output_id; //make sure that the browser supports ajax if(xml_http_request_object == null) { alert("your browser does not support ajax"); } var url = passed_url + "?" + url_variables + "&sid=" + Math.random(); //alert(url); xml_http_request_object.open("POST",url,true); xml_http_request_object.onreadystatechange = ProcessStateChange; xml_http_request_object.send(0); } function ProcessStateChange() { if(xml_http_request_object.readyState == 4 || xml_http_request_object.readyState == "complete") { document.getElementById(output_id).innerHTML = xml_http_request_object.responseText; } } and the xml_http_request_object.send(0); line is line 32 where the error is happening, any help would be great. Quote Link to comment Share on other sites More sharing options...
mainewoods Posted May 17, 2007 Share Posted May 17, 2007 var xml_http_request_object = CreateXMLHttpRequestObject(); when the second call is made, the object above ('xml_http_request_object') is already in use and waiting for onreadystatechange. The second call cannot use that obj until the first call has finished with it. The easiest way to fix your problem is to make the first call 'synchronous' as opposed to the usual 'asynchronous'. Quote Link to comment Share on other sites More sharing options...
sayedsohail Posted May 19, 2007 Share Posted May 19, 2007 how do you make synchronous? please adivse.. 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.