Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with jQuery $.get in IE
    text
    copied!<p>I have a login form which appears at the top of all of my pages when the user is logged out. My current jQuery/javascript code works in Firefox 3 but not IE 7. The code queries a page which simply returns the string "true" or "false" depending on whether the login was successful or not. Inside my $.ready() function call I have the following...</p> <pre><code>$('#login_form').submit(function() { var email = $('input#login_email').val(); var pw = $('input#login_password').val() $.get('/user/login.php', { login_email: email, login_password: pw }, function(data) { alert('get succeeded'); if(data == 'true') { $('#login_error').hide(); window.location = '/user/home.php'; alert('true'); } else { $('#login_error').show(); alert('false'); } }); alert('called'); return false; }); </code></pre> <p>In FF, I am successfully transferred to the intended page. In IE, however, the below alerts "called" and nothing else. When I refresh the page, I can see that I am logged in so the $.get call is clearly going through, but the callback function doesn't seem like its being called (ie. "get succeeded" is not popping up). I also don't appear to be getting any javascript error messages either.</p> <p>Why isn't this working in IE?</p> <p>Thanks</p> <p><strong>EDIT:</strong> Since a couple people asked, whenever I enter a correct email/password or an incorrect one, nothing in the callback function happens. If I manually refresh the page after entering a correct one, I am logged in. Otherwise, I am not.</p> <p><strong>EDIT 2:</strong> If I alert out <code>data</code> in the callback function nothing happens in IE (I do not get an alert popup). In FF, it alerts <code>true</code> for valid email/pw combos and <code>false</code> for invalid ones. I am using jQuery 1.3.2.</p> <p><strong>EDIT 3:</strong> Ok, guys, I tried R. Bemrose's thing down there and I'm getting a "parseerror" on the returned data. I'm simply echoing 'true' or 'false' from the other PHP script. I also tried 'yes' and 'no', but that still gave me a parse error. Also, this works in Chrome in addition to FF.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload