我想使用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) –