473,320 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Ns_error_not_initialized

Yes. another one.

This is not my first httprequest site, but it is only my second. I didn't have any
issues the first run through. the error produced is:
Expand|Select|Wrap|Line Numbers
  1. Error: uncaught exception: 
  2. [Exception... "Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIXMLHttpRequest.send]"  nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)"  location: "JS frame :: http://whathuhstudios.com/westside_dev/ :: sndReq :: line 32"  data: no]
  3.  
here is the code that is being excecuted. The startajax() runs from an onclick

Expand|Select|Wrap|Line Numbers
  1. var browser = navigator.appName;
  2.  
  3. function startajax()
  4. {
  5. sndReq(document.getElementById('catagorylist').value,'providerlist.php', 'test');
  6.  
  7. }
  8.  
  9. function createRequestObject() {
  10.     var ro;
  11.     if(browser == "Microsoft Internet Explorer"){
  12.         ro = new ActiveXObject("Microsoft.XMLHTTP");
  13.     }else{
  14.         ro = new XMLHttpRequest();
  15.     }
  16.     return ro;
  17. }
  18. var http = createRequestObject();
  19.  
  20.  
  21. function sndReq(request, ajax_file, targeturi) {
  22.     var requesturi = 'ajax/' + ajax_file ;
  23.     document.getElementById(targeturi).innerHTML = requesturi;     
  24.     http.onreadystatechange = new Function(handleResponse(targeturi));
  25.     http.send(null);
  26. }
  27.  
  28. function handleResponse(targeturi) {
  29.     if(http.readyState == 4) {
  30.         var response = http.responseText;
  31.          document.getElementById(targeturi).innerHTML = response;     
  32.     }
  33. }
Feb 22 '07 #1
4 9464
acoder
16,027 Expert Mod 8TB
Never use browser detection, always use object detection.
Use something similar to the following instead:
Expand|Select|Wrap|Line Numbers
  1. function GetXmlHttpObject() {
  2.   var xmlhttp;
  3.   if (window.XMLHttpRequest) { // Mozilla, Safari, Opera...
  4.     xmlhttp = new XMLHttpRequest();
  5.     //if (xmlhttp.overrideMimeType) xmlhttp.overrideMimeType('text/xml');
  6.   } else if (window.ActiveXObject) { // IE
  7.       try {
  8.         xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  9.       } catch (e) {
  10.           try {
  11.             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  12.           } catch (e) {}
  13.       }
  14.   }
  15.   if (!xmlhttp) {
  16.     alert('Cannot create an XMLHTTP instance');
  17.     return false;
  18.   }
  19.   return xmlhttp;
  20. }
Feb 23 '07 #2
acoder
16,027 Expert Mod 8TB
You also need to use the open method to send a request to the server:
Expand|Select|Wrap|Line Numbers
  1. xmlHttp.open("GET",requesturi,true);
Feb 23 '07 #3
Oh my GOD I'm an idiot. I had this script working on another site, and i must have deleted the line and not noticed it... no wonder the readystate never changed.

Thank you for your help, I appreciate it very much.
Feb 23 '07 #4
acoder
16,027 Expert Mod 8TB
No problem. You're welcome.
Feb 26 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: seanism | last post by:
Hello all I am new to javascript and I am attempting to write a site in JS / PHP to jump on the ajax band wagon. I am getting the following error and have not been able to locate a solution for it...
3
by: harishdixit1 | last post by:
Hello friends i m calling a javascript function from toolbar on the web page . but on statement xmlHTTPReq.send( data ); exception occurs. execption is "Component returned failure code:...
4
by: tromboneman | last post by:
Hi! I haven't been coding in Javascript/PHP very long, but this is the first thing some time and Google can't solve. Through my hours of debugging, I have narrowed the problem down to...
35
by: Kaante | last post by:
Hi, i want a frame on my website to display one pic if the user has new messages and another different pic if it dsnt. Before i used html to auto refresh page every 10 secs. that was annoying...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.