我想使用jquery获取发布数据。我有implemen使用jquery获取发布数据
HTML表单
<form id="login_form" action="userPref.php" method="post" >
<div hidden id="error" style="color:red; text-align:center;" > <p> user not found </p> </div>
<div class="form-group">
<label for="usrname"><span class="glyphicon glyphicon-user "></span> User Id</label>
<input type="text" value="" class="form-control" required="required" id="usrname" name="usrname" placeholder="Enter User Id" >
</div>
<button type="submit" id="login" class="btn btn-success btn-block"><span class="glyphicon glyphicon-off"></span> Login</button>
</form>
在userPref.php我使用PHP来获得数据,但其实我是想使用jquery
var userid = <?php echo $_POST["usrname"] ?>;
我也试图访问表单数据使用jquery,但我无法访问数据。请帮帮我。
有很多教程和例子。其中一个http://www.htmlgoodies.com/tutorials/forms/article.php/3895776或只是谷歌,你会发现他们的吨。 – ProgrammerV5
[jQuery Ajax POST示例与PHP]可能重复(http://stackoverflow.com/questions/5004233/jquery-ajax-post-example-with-php) –