CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Threaded View

  1. #1
    Join Date
    Oct 2008
    Location
    Richmond, VA
    Posts
    24

    AJAX not working with Firefox

    This AJAX works fine in IE 6, but nothing happens in Firefox


    This is the html of the page:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Resolution Center Testing</title>
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <script type="text/javascript" src="../js/sorttable.js"></script>
    <script type="text/javascript" src="js/rpc.js"></script>
    </head>
    <body>
    <table><tr><td>
    <div id="menu">
    
    
    <input type="button" class="link" value="Create/Edit Users" onclick="getUsers();"/><br/><br/>
    <input type="button" class="link" value="Create/Edit Test" onclick="getTests();"/><br/><br/>
    <input type="button" class="link" value="Unlock Test" onclick="getUnlock();"/><br/><br/>
    <input type="button" class="link" value="Grade Test" onclick="getGrade();"/><br/><br/>
    <input type="button" class="link" value="View Active Test" onclick="getActive();"/><br/><br/>
    
    </div>
    
    </td><td>
    
    <div id="admin_box">
    </div>
    
    
    
    </td></tr></table>
    
    
    
    </body>
    </html>
    clicking on of the buttons calls the proper javascript function, which makes the http request, and dumps that into the "admin_box" div

    here is the javascript:

    Code:
    function createRequestObject() {
            var ro;
            var browser = navigator.appName;
            if(browser == "Microsoft Internet Explorer"){
                    ro = new ActiveXObject("Microsoft.XMLHTTP");
            }else{
            ro = new XMLHttpRequest();
            }
            return ro;
    }
    
    var http = createRequestObject();
    
    
    function getUsers() {
            http.open('get', 'rpc/users.php?rand=' + Math.random() );
            http.onreadystatechange = handleAdmin;
            http.send(null);
    }
    
    function getTests() {
            http.open('get', 'rpc/tests/main.php?rand=' + Math.random() );
            http.onreadystatechange = handleAdmin;
            http.send(null);
    }
    
    function getUnlock() {
            http.open('get', 'rpc/unlock.php?rand=' + Math.random());
            http.onreadystatechange = handleAdmin;
            http.send(null);
    }
    
    function getGrade() {
            http.open('get', 'rpc/grade.php?rand=' + Math.random());
            http.onreadystatechange = handleAdmin;
            http.send(null);
    }
    
    function getActive() {
            http.open('get', 'rpc/active.php?rand=' + Math.random());
            http.onreadystatechange = handleAdmin;
            http.send(null);
    }
    
    function handleAdmin() {
            if (http.readystate == 4) {
                    document.getElementById('admin_box').innerHTML = http.responseText;
            }
    }
    All of this works perfectly fine in IE6, but not in Firefox.
    In firefox the buttons show up, but if you click any of them, nothing happens at all. An no errors show in the error console.

    The thing that really bothers me about this is there is another part of my web site that works fine in firefox and it uses IDENTICAL javascript (with the exception of URLs of course).

    If anyone could give me any guidance on this issue, I would be extremely grateful.

    Thank you for your time
    Last edited by PeejAvery; October 22nd, 2008 at 05:47 PM. Reason: Added code tags

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured