X
Tap here to go to the mobile version of the site.

Support Forum

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

Posted

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>

Modified by cor-el

Additional System Details

Application

  • User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36

More Information

jscher2000
  • Top 10 Contributor
8198 solutions 67055 answers

Helpful Reply

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

Hi sherryleithner, you need to put &lt;pre> before and &lt;/pre> after any code you post here to make it readable (and preferably replace &lt; brackets with &amp;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]]

Question owner

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

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. <pre> 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> </pre> <pre> console.log("The following error occurred: "+ xhr.responseText + " textStatus= " + textStatus + " xhr.error= " + xhr.error + " errorThrown= " +errorThrown); console.log(e); </pre> '''My xhr.responseText is undefined not sure why''

Modified by sherryleithner