表单提交 事件

$.post(url,{"":,"random":Math.random()},function(data){});这种方式提交的数据可以得到后台返回的结果

 

$.ajax({
    cache: true,
    type: "POST",
    url:ajaxCallUrl,
    data:$('#yourformid').serialize(),// 你的formid
    async: false,
    error: function(request) {
      alert("Connection error");
    },
    success: function(data) {
  $("#commonLayout_appcreshi").parent().html(data);
       }
});
 
--------------------------------------------------------------------------------------------------------

ajax提交整个form表单

 

来源:http://blog.csdn.net/tolcf/article/details/41151195

在项目开发中,有时提交form表单时不能只使用action或者jQuery



表单提交方法有三种,主要说下第三种
第一种:用 form 自带属性action 提交
第二种:用 jquery 提交:$("#formid").submit();
第三种:用 ajax 提交:
但如果form表单中数据很多时,不可能一一列出,只需要用
$('#yourformid').serialize()就可以了

举例如下:

$.ajax({
	cache: true,
	type: "POST",
	url:  ajaxCallUrl,
	data: $('#yourformid').serialize(),// 你的formid
	async: false,
	error: function(request) {
		alert("Connection error");
	},
	success: function(data) {
		$("#commonLayout_appcreshi").parent().html(data);\
	}
});
posted @ 2017-08-25 10:52  \面朝阳光/  阅读(518)  评论(0编辑  收藏  举报