Jquery $.Post works in Firefox but not Chrome
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.
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...
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.
Chrome and jquery dont play nice in terms of POST. That's the short story. Try upgrading to the latest version of JQuery.
链接地址: http://www.djcxy.com/p/17332.html