jQuery Ajax: $.post请求示例
生活随笔
收集整理的這篇文章主要介紹了
jQuery Ajax: $.post请求示例
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
jQuery Ajax:?$.post請求示例
leyangjun.html頁面
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="./jquery-2.0.0.min.js"></script>
<script>
?$(document).ready(function(){
? $("#sub").click(function(){
? ?$.post("leyangjun.php",{name:$("#name").val()},function(data,textStatus){
? ? $("#result").append("data:"+data.name);
$("#result").append("<br>age:"+data.age);
? ? $("#result").append("<br>textStatus:"+textStatus);
? ?},"json");
? ?return false;
? });
?});
</script>
</head>
<body>
<form action="testPost.php" method="post">
?<input type="text" name="name" id="name" >
?<input type="submit" id="sub" value="提交">
</form>
<h2>頁面顯示回來的內容</h2>
<div id="result"></div>
</body>
</html>
相應的頁面leyangjun.php
<?php?
echo json_encode(
array(
"name" => $_POST['name'],
"age" => 110,
)
);
?
>
本文轉自mfrbuaa博客園博客,原文鏈接:http://www.cnblogs.com/mfrbuaa/p/5038299.html,如需轉載請自行聯系原作者
總結
以上是生活随笔為你收集整理的jQuery Ajax: $.post请求示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: RHEL7基本操作
- 下一篇: 分享Silverlight/WPF/Wi