Cerca nel supporto

Attenzione alle mail truffa. Mozilla non chiederà mai di chiamare o mandare messaggi a un numero di telefono o di inviare dati personali. Segnalare qualsiasi attività sospetta utilizzando l'opzione “Segnala abuso”.

Ulteriori informazioni

Questa discussione è archiviata. Inserire una nuova richiesta se occorre aiuto.

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

  • 2 risposte
  • 2 hanno questo problema
  • 24 visualizzazioni
  • Ultima risposta di sherryleithner

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>

Modificato da cor-el il

Tutte le risposte (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

Modificato da sherryleithner il