1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Issues with FireFox and Javascript/AJAX

Discussion in 'Tech Support' started by TheSaladMan, 31 Jul 2007.

  1. TheSaladMan

    TheSaladMan What's a Dremel?

    Joined:
    15 Sep 2006
    Posts:
    135
    Likes Received:
    0
    Not 100% sure this is the right place for this but here goes

    Yea so I'm having a lot of issues atm with this piece of code I'm writing for a personal website, it works in IE but if I try to run it in FF nothing happens, I've got the developer toolbar and the javascript console open but they don't give me any feedback whatsoever. Anyway, here's the code:

    Code:
    function getRequest(){
    	var xmlHttp=null;
    	try{
    		http=new XMLHttpRequest();
    	}
    	catch(e){
    		try{
    			http=new ActiveXObject("Msxml12.XMLHHTP");
    		}
    		catch(e){
    			try{
    				http=new ActiveXObject("Microsoft.XMLHTTP");
    			}
    			catch(e){
    				alert("Do you live in the 90's? Get a modern browser that supports AJAX!");
    				return false;
    			}
    		}
    	}
    	return http;
    }
    function loadData(){
    	var http;
    	http=getRequest();
    	http.open("GET","ajax/flash.html",true);
    	http.send(null);
    	http.onreadystatechange=showResponse();
    }
    function showResponse(){
    	if(http.readyState==4){
    			var put = http.responseText;
    			//alert(http.responseText);
    			document.getElementById("txtPageData").innerHTML=http.responseText
    			//document.write.put;
    	}
    }
    Personally I think it's something to do with the last few lines (hence all the commented out stuff) but I'm still quite new to JS and it's rather confusing as it doesn't give you nearly as much feedback as PHP or Actionscript.

    Ps this is all in an external JS file which I've referenced with the following lines inside my HTML:

    Code:
    <script type="text/javascript" src="ajax/ajax.js"></script>
    <a onclick="loadData();" href="#">
    <span id="txtPageData"></span>
     

Share This Page