网络编程 
首页 > 网络编程 > 浏览文章

ajaxForm和ajaxSubmit 粘贴就可用示例代码

(编辑:jimmy 日期: 2024/11/15 浏览:3 次 )
复制代码 代码如下:
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="/UploadFiles/2021-04-02/jquery-1.7.2.min.js"><script src="jquery.form.js"><script>
//ajaxForm
var optionss = {
dataType:"text",
type:'post',
url: "chuli.php",
beforeSubmit:showRequest,
success:showResponse,
clearForm:true
};
$('#form1').ajaxForm(optionss);
function showRequest() { }
function showResponse(data){
alert(data);
}
</script>
</head>
<body>
<form action="chuli.php" method="post" id="form1">
<input type="text" name="name" />
<input type="text" name="sex" />
<input type="submit" value="提交"/>
</form>
<hr />
<form action="chuli.php" method="post" id="form2">
<input type="text" name="name" />
<input type="text" name="sex" />
<input type="button" id="tijiao" value="提交"/>
</form>
</body>
<script>
//ajaxSubmit
$("#tijiao").click(function(){
$("#form2").ajaxSubmit({
success:function(data){
alert(data);
}
})
});
</script>
</html>
上一篇:比getjson好的底层函数是哪个有什么优点
下一篇:js基本ajax写法示例代码