标签:gif swa each turn 表单 wal else ret for
<script> $(function(){ //表单转json函数 $.fn.serializeObject = function(){ var o = {}; var a = this.serializeArray(); $.each(a, function() { if (o[this.name] !== undefined) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ‘‘); } else { o[this.name] = this.value || ‘‘; } }); return o; }; //表单转json结束 $(‘#add_po‘).click(function(){ $.ajax({ url:"/scf/purchase/add.do", //接口地址 type:"post", data:JSON.stringify($(‘#po_add_form1‘).serializeObject()) + ‘&‘ + JSON.stringify($(‘#add_po_form‘).serializeObject()),//将表单序列化成一个对象,这里多个表单相加
//serializeObject()引入上述函数,将表单序列化成一个对象
//JSON.stringify()将对象转成字符串 contentType: ‘application/json‘, datatype:"json", success:function(data){ swal(data.message); //location.href="scm_po_fhqd.html"; },error: function(XMLHttpRequest) { console.log("错误状态:"+XMLHttpRequest.status); } }) }) }) </script>
标签:gif swa each turn 表单 wal else ret for
原文地址:http://www.cnblogs.com/wangdahai/p/6060668.html