<html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script> <script src="./testajaxjs.js"></script> <head> </head> <body> <form id="form1"> <p>xingming:<input type="text" name="xingming"/></p> <p>nianling:<input type="text" name="nianling"/></p> </form> <button type="button" id="mybt" onclick="mysubmmit()"> ajax提交 </button> </body> </html>
function mysubmmit(){
$.ajax({
type: "POST",
url: "testajaxend.php",
data: $('#form1').serialize(),
async: false,
success: function(databack){
//console.log("chenggong");
console.log(databack);
},
error: function(request){
console.log("shibaile");
}
});
}
<?php
$name = $_POST['xingming'];
$age = $_POST['nianling'];
$myarray = array("name"=>$name, "age"=>$age);
$myjson = json_encode($myarray);
echo $myjson;
?>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有