Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    my script is not running on fire fox

    Hi

    i am using Php with ajax i found some problem in my scrip ,my site is running only IE but not in fire fox

    my .js file

    var xmlhttp=false;
    try{
    xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {

    try

    {

    xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
    }catch(E)

    {
    xmlHTTP=false;

    }
    }





    function request (page,objDiv)

    {

    var serverPage =page + "?time=" + new Date().getTime();
    var obj= document.getElementById(objDiv);

    obj.innerHTML="<img src=images/blu.gif width=16 height=16 id=loading align=center><br><font size=1 face=Verdana, Arial, Helvetica, sans-serif>Performing Specified Action...</font>";

    xmlhttp.open("GET",serverPage);
    xmlhttp.onreadystatechange=function()
    {
    if (xmlhttp.readystate== 4 && xmlhttp.status== 200)
    {
    obj.innerHTML=xmlhttp.responseText;


    }

    }


    xmlhttp.send(null);

    }



    what can i add then my script is running

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Only IE supports ActiveX objects.

    You could use a wrapper function to return an XMLHTTP object:

    Code:
    function createXMLHttpRequest() {
       try { return new XMLHttpRequest(); } catch(e) {}
       try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
       alert("XMLHttpRequest not supported");
       return null;
     }
     var xhReq = createXMLHttpRequest();
    Why bother reinventing the wheel though? Let a framework do all the heavy lifting:

    Code:
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script type="text/javascript">
    function request (page, objDiv){
    	var timestamp = new Date().getTime();
    	$(objDiv).html('<img src="images/blu.gif" width="16" height="16" id="loading" align="center"><br><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Performing Specified Action...</font>');
    	$.get(page, {'time' : timestamp}, function(response){
    		$(objDiv).html(response);
    	});
    }
    </script>


  •  

    Posting Permissions

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