Guest User

Untitled

a guest
Apr 24th, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. Form validation via jQuery.post with .val() returning 'null' error
  2. <script type="text/javascript" src="inc/jquery-1.7.1.min.js" type="text/javascript"></script>
  3. <script type="text/javascript">
  4. jQuery.noConflict();
  5. jQuery(document).ready(function() {
  6. jQuery("#login_form").submit(function() {
  7. jQuery("#msgbox").removeClass()
  8. .addClass('messagebox')
  9. .text('verifying')
  10. .fadeIn(1000);
  11.  
  12. jQuery.post("inc/ajax_login.php", {
  13. user_name: $('#username').val(),
  14. password: $('#password').val()
  15. }, function(data) {
  16. if (data == 'yes') { /* ... */
  17. }
  18. else { /* ... */
  19. }
  20. });
  21. return false;
  22. });
  23. });​
  24. </script>
  25.  
  26. <form action="" id="login_form" method="POST">
  27. <input type="text" name="username" id="username" value="username" />
  28. <input type="password" name="password" id="password" value="password" /><br />
  29. <input type="hidden" name="homeDir" id="homeDir" value="" /> <span id="msgbox"></span> <br />
  30. <input type="submit" name="Submit" id="submit" value="ENTER" class="submit"/>
  31. </form>
  32.  
  33. <script>
  34.  
  35. jQuery.noConflict();
  36.  
  37. (function($) {
  38. $("#login_form").submit(function()
  39. {
  40. $("#msgbox").removeClass().addClass('messagebox').text('verifying').fadeIn(1000);
  41.  
  42. $.post("inc/ajax_login.php", {
  43. user_name: $('#username').val(),
  44. password: $('#password').val()
  45. }, function(data) {
  46. if(data=='yes') {/* ... */}
  47. else {/* ... */}
  48. });
  49.  
  50. return false;
  51. });
  52. })(jQuery);
  53.  
  54. </script>
Advertisement
Add Comment
Please, Sign In to add comment