Web Analytics Made Easy -
StatCounter xmlhttp.status problem - CodingForum

Announcement

Collapse
No announcement yet.

xmlhttp.status problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • xmlhttp.status problem

    I'm having trouble with a bit of code I'm working on that I've never come accross before, whenever I try to check the xmlhttp.status I get this error (in FF)
    Code:
    Error: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]"  nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"  location: "JS frame :: http://localhost/business_centre/ads.php :: handleResponse :: line 58"  data: no]
    Source File: http://localhost/business_centre/ads.php
    Line: 58
    My Code is
    Code:
    <script type = "text/javascript">
    	onload = function()
    	{
      	try
    		  {
    		    xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
    		   }
    		   catch(e)
    		   {
    		     alert('cannot create');
    		   }
    	}
    	
    function generate()
    {
      
      args= "";
    
     document.getElementById('resultblock').innerHTML = "<img src = 'spinner.gif' />";
      for(i=0; i< document.getElementById('sform').elements.length; i++)
      {
        if(document.getElementById('sform').elements[i].type == 'select' || document.getElementById('sform').elements[i].type == 'select-one')
        {
          if(document.getElementById('sform').elements[i].options[document.getElementById('sform').elements[i].selectedIndex].value != "")
          {
    	    args += document.getElementById('sform').elements[i].name + '=' + document.getElementById('sform').elements[i].options[document.getElementById('sform').elements[i].selectedIndex].value + '&';
    	  }
    	  
    	}
    	else
    	{
    	  if(document.getElementById('sform').elements[i].value != "" && document.getElementById('sform').elements[i].name != "")
    	  {
    	    args += document.getElementById('sform').elements[i].name + '=' + document.getElementById('sform').elements[i].value + '&';
    	  }
    	  
    	}  
      }  
      args +='rand=1';
      loadURL('generatetopten.php', args);
    }
    function loadURL(url, args)
    {
    	xmlhttp.open("GET", url+"?"+args);
    	xmlhttp.onreadystatechange = handleResponse;
    	xmlhttp.send(null);
    }
    		
    function handleResponse()
    {
      if(xmlhttp.readyState == 4 && xmlhttp.status==200)
    	{
    	  alert(xmlhttp.responseText);
    	  document.getElementById('resultblock').innerHTML = xmlhttp.responseText;
    	}
    }
    </script>
    I'm not sure if that will help since its code that I've used many times before but its worth a try.

    As far as I can tell the generatetopten.php file is doing what its supposed to be doing (it outputs stuff that is also written to file for later use and that works fine). The file is written to but the output never makes it to the browser.
    Now the other interesting thing that happens is that rather than changing the contents of resultblock to spiny.gif then failing and leaving the image or making the div blank - it reverts back to whatever content was in the block before the script was called.
    Which is very weird - I've never seen that happen before and I cant think of any logical reason for this behavior.
    http://www.hazelryan.co.uk

  • #2
    Update:
    I tried running it in IE and it didnt get that error, and (some of the time) I got a response from the server, and the content of the div changed to what it should be then instantly changed back to what it was before
    http://www.hazelryan.co.uk

    Comment


    • #3
      Looks like I found the solution - I was using a submit instead of a button so the page was being reloaded.
      http://www.hazelryan.co.uk

      Comment

      Working...
      X