当前位置: 移动技术网 > IT编程>脚本编程>Ajax > ajaxForm和ajaxSubmit 粘贴就可用示例代码

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

2017年12月12日  | 移动技术网IT编程  | 我要评论
复制代码 代码如下:

<!--
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="jquery-1.7.2.min.js"></script>
<script src="jquery.form.js"></script>
<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>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网