Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

jquery function .post works on chrome & IE but not firefox

more options

I am using a jquery function with .post for logging in. This funciton works in Chrome & IE but not firefox. With firefox I have to try login more than once. The username & password are cache so I am not typing them each time.

$('#submit_login').click(function(e){
        $userLogin = $('#user_login_name').val();
        $userPassword = $('#user_password').val();
        //alert("in submit login" + $userLogin );
        $.post("login_ldap.php", {userLogin: $userLogin, userPassword: $userPassword})

                .done(function(data, status){
                        //alert("success");
                        console.log("Data: " + data + '\nStatus: ' + status);

                })
                .fail(function(xhr, textStatus, errorThrown) {
                        alert("Login error");

                        $("#login_error").text("Login Failed").delay(90000).fadeIn();   

                        console.log("The following error occured: "+ xhr.responseText + " textStatus= " + textStatus + " xhr.error=  " + xhr.error + " errorThrown=  " +errorThrown);
                        console.log(e);
                        //$('#login_error').empty().append(xhr.responseText);
                })
                .always(function() {
                        //alert("finished");
                });
         });

login_ldap.php

try {
echo  bricks_usersDB::login_ldap($userLogin, $userPassword);
    }
    catch ( Exception $e ) {

     echo "\nLOGIN ERROR: " . $e->getMessage();
     error_log($e->getMessage());

    # added header to send error back
      header("HTTP/1.0 404 Not Found");
      exit();
    }
I am using a jquery function with .post for logging in. This funciton works in Chrome & IE but not firefox. With firefox I have to try login more than once. The username & password are cache so I am not typing them each time. <pre><nowiki>$('#submit_login').click(function(e){ $userLogin = $('#user_login_name').val(); $userPassword = $('#user_password').val(); //alert("in submit login" + $userLogin ); $.post("login_ldap.php", {userLogin: $userLogin, userPassword: $userPassword}) .done(function(data, status){ //alert("success"); console.log("Data: " + data + '\nStatus: ' + status); }) .fail(function(xhr, textStatus, errorThrown) { alert("Login error"); $("#login_error").text("Login Failed").delay(90000).fadeIn(); console.log("The following error occured: "+ xhr.responseText + " textStatus= " + textStatus + " xhr.error= " + xhr.error + " errorThrown= " +errorThrown); console.log(e); //$('#login_error').empty().append(xhr.responseText); }) .always(function() { //alert("finished"); }); }); login_ldap.php try { echo bricks_usersDB::login_ldap($userLogin, $userPassword); } catch ( Exception $e ) { echo "\nLOGIN ERROR: " . $e->getMessage(); error_log($e->getMessage()); # added header to send error back header("HTTP/1.0 404 Not Found"); exit(); }</nowiki></pre>

由 cor-el 於 修改

所有回覆 (2)

more options

Hi sherryleithner, you need to put <pre> before and </pre> after any code you post here to make it readable (and preferably replace < brackets with &lt; to avoid tags being "eaten"). Alternately, you can use a Github gist or Pastebin, etc.

I can suggest checking for potentially relevant error messages in Firefox's Browser console. You can open the separate Browser Console window using either:

  • "3-bar" menu button > Web Developer > Browser Console
  • (menu bar) Tools > Web Developer > Browser Console
  • (Windows/Linux) Ctrl+Shift+j

Click the trash can icon at the upper left to clear the window, then switch back over to your main window and trigger the login action.

Then switch back over to the console window. Did Firefox log any errors related to that action?

More info on the Browser Console: https://developer.mozilla.org/docs/Tools/Browser_Console

See also: Where to go for developer support

more options

Thank you I did not look in the browser console. This is my first project and I am learning a lot. I get this error message whether login works or not. Which means my .fail is executing when login works and when it fails but only on firefox.

The following error occurred: undefined textStatus= error xhr.error=  function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this} errorThrown=  index.php:120:4

<unavailable>
console.log("The following error occurred: "+ xhr.responseText + " textStatus= " + textStatus + " xhr.error=  " + xhr.error + " errorThrown=  " +errorThrown);
console.log(e);

'My xhr.responseText is undefined not sure why

由 sherryleithner 於 修改