Results 1 to 7 of 7

Thread: Ajax script doesn't work in FireFox

  1. #1
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Exclamation Ajax script doesn't work in FireFox

    Hi all,

    I am dealing with an Ajax script and it works pretty good in IE 6.0 but not in Firefox based browsers.

    In the javascript console it gives the following error code (red color)

    Error: uncaught exception: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: http://localhost/login.js :: loginUser :: line 74" data: no

    Why this is happening only in firefox?

    The firefox browser version i am using is 1.5.0.7

    thanks in advance

    regards

    Code Exploiter

  2. #2
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    You might want to give us a link for the ajax script
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  3. #3
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    It is working in a private network won't be able to host in public

    Plz find the ajax script below

    Code:
    		var XMLHTTPREQUEST_MS_PROGIDS = new Array(
    		  "Msxml2.XMLHTTP.7.0",
    		  "Msxml2.XMLHTTP.6.0",
    		  "Msxml2.XMLHTTP.5.0",
    		  "Msxml2.XMLHTTP.4.0",
    		  "MSXML2.XMLHTTP.3.0",
    		  "MSXML2.XMLHTTP",
    		  "Microsoft.XMLHTTP"
    		);
    		
    		var XMLHTTPREQUEST_READY_STATE_UNINITIALIZED = 0;
    		var XMLHTTPREQUEST_READY_STATE_LOADING       = 1;
    		var XMLHTTPREQUEST_READY_STATE_LOADED        = 2;
    		var XMLHTTPREQUEST_READY_STATE_INTERACTIVE   = 3;
    		var XMLHTTPREQUEST_READY_STATE_COMPLETED     = 4;
    
    		var myXmlHttpRequest;
    		var theFrame;
    		var theUser = "";
    				
    		function getXMLHttpRequest()
    		{
    			alert('http request'); 
    		  var httpRequest = null;
    		  if (window.XMLHttpRequest != null) {
    		  	httpRequest = new window.XMLHttpRequest();
    		  	httpRequest.overrideMimeType('text/xml');
    		  	alert('activex supported 1'); 
    		  } else if (window.ActiveXObject != null) {
    			    var success = false;
    			    for (var i = 0;
    			         i < XMLHTTPREQUEST_MS_PROGIDS.length && !success;
    			         i++)
    			    {
    			      try
    			      {
    			       httpRequest = new ActiveXObject(XMLHTTPREQUEST_MS_PROGIDS[i]);
    			        success = true;
    			        alert('activex supported 2'); 
    			      }
    			      catch (ex) {
    			      	alert('activex not supported ex'); 
    			      	}
    			    }
    		  }
    		  if (httpRequest == null)
    		    alert("Error in HttpRequest():\n\n"+ "Cannot create an XMLHttpRequest object.");
    		  return httpRequest;
    		}
    
    		function loadFrame(frm, page, user, pswd) {
    			theFrame = frm;
    			theUser = user;
    			var lblStatus = theFrame.document.getElementById('lblStatus');
    			if (lblStatus != null) {
    				lblStatus.style.visibility="visible";
    			}			
    		  myXmlHttpRequest = getXMLHttpRequest();
    			alert(myXmlHttpRequest);
    			var encodedStr='Basic '+encode64(user+ ':' +pswd);
    			myXmlHttpRequest.open('GET',page, true);
    			isBusy = true;
    			myXmlHttpRequest.onreadystatechange = loginUser();
    			myXmlHttpRequest.setRequestHeader("Authorization", encodedStr);
    			myXmlHttpRequest.setRequestHeader("User-Agent", "login");
    			myXmlHttpRequest.send("");
    			
    		}
    
    		 function loginUser(){
    		 	
    		 	alert(myXmlHttpRequest);
    	   	if(myXmlHttpRequest.readyState == 4){
    	        if(myXmlHttpRequest.status == 200 ){
    	        	       	
    
    								var resText=myXmlHttpRequest.responseTEXT;
    								alert("resText"+resText);
    		           	var newString=resText.replace(/@@@@/g, theUser);
    								theFrame.document.writeln(newString);
    								theFrame.document.close();
    	         } else if(myXmlHttpRequest.status == 403){
    							var lblStatus = theFrame.document.getElementById('lblStatus');
    							if (lblStatus != null) {
    								lblStatus.style.visibility="hidden";
    							}	
    				      alert('Invalid User Name or Password.       \nPlease try again.\n');
    	          	theFrame.reload(true);
    	         } else {
    							var lblStatus = theFrame.document.getElementById('lblStatus');
    							if (lblStatus != null) {
    								lblStatus.style.visibility="hidden";
    							}	
    				      alert('Invalid User Name or Password.       \nPlease try again.\n');
    	          	alert('error - could not access the pump');
    	         }
    	       }
    		
    		
    	    }
    
    
    		  function encode64(input) 
    		  {
    					var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789=';
    		      var output = '';
    		      var chr1, chr2, chr3 = '';
    		      var enc1, enc2, enc3, enc4 = '';
    		      var i = 0;
    			
    		      do {
    		         chr1 = input.charCodeAt(i++);
    		         chr2 = input.charCodeAt(i++);
    		         chr3 = input.charCodeAt(i++);
    			
    		         enc1 = chr1 >> 2;
    		         enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
    		         enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
    		         enc4 = chr3 & 63;
    			
    		         if (isNaN(chr2)) {
    		            enc3 = enc4 = 64;
    		         } else if (isNaN(chr3)) {
    		            enc4 = 64;
    		         }
    			
    		         output = output +
    		            keyStr.charAt(enc1) +
    		            keyStr.charAt(enc2) +
    		            keyStr.charAt(enc3) +
    		            keyStr.charAt(enc4);
    		         chr1 = chr2 = chr3 = '';
    		         enc1 = enc2 = enc3 = enc4 = '';
    		      } while (i < input.length);
    			
    		      return output;
    		  }
    and it creates the problem in Firefox when it encounter the following line

    Code:
    myXmlHttpRequest.status

  4. #4
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    I am not a JS or AJAX guy, but I came accross this thread: http://www.thescripts.com/forum/thre...6534-2-10.html

    and in it, someone had the exact same error with the exact same line. I read it but made me dizzy. I *think* it got fixed.

    Hope it helps
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  5. #5
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    I've figured it out now it works without any probs

  6. #6
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by codeexploiter
    It is working in a private network won't be able to host in public
    True, but you could produce a public example that demonstrates the problem.

    httpRequest.overrideMimeType('text/xml');
    If you use that method at all, you should test for it first. Opera didn't support it the last time I checked, and I doubt that IE7 will, either.

    You shouldn't need it, anyway. Just make sure that the server sends back a text/xml or application/xml Content-Type header value.

    try {
    httpRequest = new ActiveXObject(XMLHTTPREQUEST_MS_PROGIDS[i]);
    Normally I wouldn't recommend openly using exception handling, but it shouldn't be an issue on a private network. On the Web, use Microsoft's conditional compilation (a JScript feature) to expose it to JScript 5 or later.

    myXmlHttpRequest.onreadystatechange = loginUser();
    This is possibly your problem: you're calling this function, rather than assigning a reference to it to the onreadystatechange property.

    Mike

  7. #7
    Join Date
    Sep 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please post solution

    Quote Originally Posted by codeexploiter View Post
    I've figured it out now it works without any probs
    Hello. I have same problem... can you please share the solution?

    thanks
    .henkedo

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •