0

I'm using Jquery to pass POST data to PHP scripts, however the function only seems to work on Firefox and not function on chrome. Here is an example Jquery post for logging in that fails:

   $(document).ready(function() {
      $("#loginform").submit(function() {
         var username = $("#username").val();
         var password = $("#password").val();
         $.post("ex.php", { 
            username: username,
            password: password }, 
            function(data) {
               $("#response").hide().html(data).show('fade','fast' );
               });
            return false;
         });
      });

Instead of functioning like a proper AJAX request as it does in Firefox, it simply refreshes the page in Chrome.

Any ideas?

Thanks.

3 Answers3

1

you are not sending the correct variables, maybe?

unameval: username ,
pwordval: password }, 

I mean you assign the values to username and password variables but never use them and send unameval and pwordval instead. If unameval is not defined, browser would err and not continue. Firefox may have the correct version you accidentally changed later on cache, so keeps working. Maybe, maybe...

Ege Özcan
  • 13,971
  • 2
  • 30
  • 51
  • no thats not it. Sorry, I actually changed unameval to username so it would be easier to understand my post. I forgot to change it in the post function too. I'll go fix that – Misanthrope Dec 12 '10 at 02:26
  • ...and e.preventDefault(); -> instead of returning false – Ege Özcan Dec 12 '10 at 02:35
  • 2
    I found the main culprit, it was just a useless random piece of code that Firefox ignored but Chrome tripped up on. I added your suggestions as well, that might have helped too. If anyone developing primarily on Firefox notices an issue with chrome, Chrome has a great built in set of developer tools; Shift+Ctrl+I to use it. Thanks for your help everyone. – Misanthrope Dec 12 '10 at 03:35
  • Thanks for the tip on the developer tool, That looks nearly as great as firebug! – SuperRoach Dec 12 '10 at 04:24
0

Chrome and jquery dont play nice in terms of POST. That's the short story. Try upgrading to the latest version of JQuery.

Sheena
  • 15,590
  • 14
  • 75
  • 113
0

I had a simple problem of not converting some post data .toString()

The code worked in some other browsers but not in chrome. HTH someone out there.

JobJob
  • 3,822
  • 3
  • 33
  • 34