javascript - jQuery post via HTML Form -
site searched on different sites don't find solution form/html file. i'm new in , don't know why code wont work, please review code , can tell me wrong ? (this me easiest way learn it)
<!doctype html> <html> <head> <script src="jquery-1.9.1.js"></script> </head> <body> <form id="formoid" action="site" title="" method="post"> <div> <label class="title">first name</label> <input type="text" id="name" name="name" value="" > </div> <div> <label class="title">name</label> <input type="text" id="name2" name="name2" value=""> <input name="authenticity_token" type="hidden" value="token_value"> </div> <div> <input type="submit" id="submitbutton" name="submitbutton" value="submit"> </div> </form> <script type='text/javascript'> /* attach submit handler form */ $("#formoid").submit(function(event) { /* stop form submitting */ event.preventdefault(); /* send data using post */ $.post( 'site/login', { authenticity_token: $('#authenticity_token').val(), username: $('#name').val(), password: $('#name2').val() }, function(responsepage,statustext,result) { console.log(responsepage); } ); }); </script> </body> </html>
thanks helping :)!
<html> <head> <script src="http://code.jquery.com/jquery-1.10.2.js"></script> <style type="text/css"> .selected{ background-color : green; } </style> <script> $(document).ready(function () { $("#formoid").submit(function (event) { /* stop form submitting */ event.preventdefault(); /* send data using post */ $.post('login_1.asp', { authenticity_token: $('#authenticity_token').val(), username: $('#name').val(), password: $('#name2').val() }, function (responsepage, statustext, result) { alert("response server---" + responsepage); } ); }); }); </script> </head> <body> <form id="formoid" action="site" title="" method="post"> <div> <label class="title">first name</label> <input type="text" id="name" name="name" value="" > </div> <div> <label class="title">name</label> <input type="text" id="name2" name="name2" value=""> <input name="authenticity_token" type="hidden" value="token_value"> </div> <div> <input type="submit" id="submitbutton" name="submitbutton" value="submit"> </div> </form> </body> </html>
login_1.asp
<% response.write request.form("username") + "---------------" + request.form("password") %>
Comments
Post a Comment