Page 1 of 1

Prevent Gecko XML "no element found" error on HTTP 204?

Posted: Fri Jun 26, 2009 3:13 pm
by JAB Creations
I'm trying to avoid having Gecko spawn the XML error message "no element found" when the server heads 204 (no content) intentionally.

I'm only trying to add content (which is handled by the function ajax_page_loadpage_platform) if there is XML. No other browser spawns this error in the console.

Here is the cleaned up version of the function and I've tried arranging onreadystatechange, readyState, and status in numerous ways to avoid the issue. I do not want to have the server respond with anything except HTTP header 204 for no content with content...if there is no content. Thoughts please?

Code: Select all

function ajax_page_platform(url,el_id,el_pos,xml_id,thefocus){ if (window.XMLHttpRequest) {var xmlhttp = new XMLHttpRequest();} else if (window.ActiveXObject) {try {xmlhttp = new ActiveXObject('Msxml2.XMLHTTP')} catch (e) {try{xmlhttp = new ActiveXObject('Microsoft.XMLHTTP')} catch (e){}}} else {alert('Error: Your browser does not seem to support AJAX.');}  var bust_split = url.split('?');  var bustcacheparameter=(url.indexOf('?')!=-1)? '&'+new Date().getTime() : '?'+new Date().getTime() xmlhttp.open('GET', url+bustcacheparameter, true); xmlhttp.send(null);  xmlhttp.onreadystatechange=function() {  alert('1 '+el_id+'\n'+xmlhttp.status);  if (xmlhttp.readyState=='4')  {   if (xmlhttp.status=='200')   {    alert('2 '+el_id+'\n'+xmlhttp.status);    ajax_page_loadpage_platform(xmlhttp,el_id,el_pos,xml_id,thefocus);   }  } }}

Re: Prevent Gecko XML "no element found" error on HTTP 204?

Posted: Fri Jun 26, 2009 3:38 pm
by JAB Creations
Scratch that, I figured it out with more conceptual thinking...

It turns out that setting the header as text/xml even when HTTP 204 is set spawns the error. To remove the error I moved the PHP header unless there was content, and no header is actually set for the mime when the HTTP is 204.