Jump to content

CrazyMerlin

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

CrazyMerlin's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey guys, Well I finally succumb to the fact that I had to use ajax. I wrote a script that in IE works like a dream and is very fast. In firefox however , the readystate never seems to change to 4! The data I was trying to get was http://70.87.49.164/rpc.php?cmd=getSurveyData&sid=2 which as you can see, even in FF returns just fine. And the client and server files are both on the same machine! So how come my damn script works in IE but not FF. Any help greatly appreciated. [code] function doSurveySelect(selector, site_url) { survey_idx = selector[selector.selectedIndex].value; xmlHttp = createXMLHttpRequest(); var url = site_url + 'rpc.php?cmd=getSurveyData&sid=' + survey_idx; xmlHttp.open('GET', url, true); xmlHttp.onreadystatechange = function() { if(xmlHttp.responseXML.childNodes.length > 0) { surveyDataToForm(); } } try { xmlHttp.send(null); } catch(e) { return throwError('surv_form', e.description); } return; } function surveyDataToForm() { if(xmlHttp.status == 200) { //do some error checking/handling if(xmlHttp.responseXML.documentElement && xmlHttp.responseXML.documentElement.hasChildNodes) { if(xmlHttp.responseXML.documentElement.firstChild.nodeName == 'error') { var error_text = xmlHttp.responseXML.documentElement.firstChild.text.toString(); error_text = "XML-RPC Error: " + error_text; return throwError('surv_form', error_text); } } else { var error_text = "No data returned from query!"; error_text = "XML-RPC Error: " + error_text; return throwError('surv_form', error_text); } //populate form with gotten values . . . . } else { alert("Document not ready!"); } } function createXMLHttpRequest() { if(window.XMLHttpRequest) { return new XMLHttpRequest(); } else if(window.ActiveXObject) { return new ActiveXObject("Msxml2.XMLHTTP"); if(!xmlHttp) { return new ActiveXObject("Microsoft.XMLHTTP"); } } } [/code] I know I should be checking for xmlHttp.readystate == 4, but when I do it never ever changes in IE or FF and so I get nothing...at least this way it works in IE. Thx!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.