ajax 批量提交

WBOY
WBOYOriginal
2016-06-23 13:57:211068browse



每一行是一条订单  现在给订单加备注  不知道怎么能实现批量提交  求思路


回复讨论(解决方案)

把他当成表单不是一样的吗,和批量删除一样
另外可以在备注文本框加个onchange事件,修改后自动AJAX提交

client.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <meta http-equiv="content-type" content="text/html; charset=utf-8">  <title> client post</title>  <script src="//code.jquery.com/jquery-1.11.0.min.js"></script> </head> <body>  <script type="text/javascript">  function fsubmit(){		var bzArray = '';		$("input[name='bz[]']").each(function(){			bzArray+= "&bz[" + $(this).attr('oid') + "]="+$(this).val(); 		});		$.post("server.php", bzArray,function(ret){			alert(ret);		});  }  </script>  <input type="button" value="批量提交" onclick="fsubmit()">  <table>   <tr>     <td>编号</td>     <td>名称</td>     <td>价格</td>     <td>备注</td>     <td>时间</td>   </tr>   <tr>     <td>5121653</td>     <td>orer name 1</td>     <td>20</td>     <td><input type="text" oid="5121653" name="bz[]"></td>     <td>1970-01-01 00:00:20</td>   </tr>   <tr>     <td>5121654</td>     <td>orer name 2</td>     <td>30</td>     <td><input type="text" oid="5121654" name="bz[]"></td>     <td>1970-01-01 00:00:30</td>   </tr>   <tr>     <td>5121655</td>     <td>orer name 3</td>     <td>50</td>     <td><input type="text" oid="5121655" name="bz[]"></td>     <td>1970-01-01 00:00:50</td>   </tr>     <tr>     <td>5121657</td>     <td>orer name 4</td>     <td>40</td>     <td><input type="text" oid="5121657" name="bz[]"></td>     <td>1970-01-01 00:00:40</td>   </tr>    </table>  </body></html>


server.php 获取提交的备注与order id
<?php$bz = $_POST['bz'];foreach($bz as $key=>$val){    echo $key.'='.$val."\r\n";}?>

client.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <meta http-equiv="content-type" content="text/html; charset=utf-8">  <title> client post</title>  <script src="//code.jquery.com/jquery-1.11.0.min.js"></script> </head> <body>  <script type="text/javascript">  function fsubmit(){		var bzArray = '';		$("input[name='bz[]']").each(function(){			bzArray+= "&bz[" + $(this).attr('oid') + "]="+$(this).val(); 		});		$.post("server.php", bzArray,function(ret){			alert(ret);		});  }  </script>  <input type="button" value="批量提交" onclick="fsubmit()">  <table>   <tr>     <td>编号</td>     <td>名称</td>     <td>价格</td>     <td>备注</td>     <td>时间</td>   </tr>   <tr>     <td>5121653</td>     <td>orer name 1</td>     <td>20</td>     <td><input type="text" oid="5121653" name="bz[]"></td>     <td>1970-01-01 00:00:20</td>   </tr>   <tr>     <td>5121654</td>     <td>orer name 2</td>     <td>30</td>     <td><input type="text" oid="5121654" name="bz[]"></td>     <td>1970-01-01 00:00:30</td>   </tr>   <tr>     <td>5121655</td>     <td>orer name 3</td>     <td>50</td>     <td><input type="text" oid="5121655" name="bz[]"></td>     <td>1970-01-01 00:00:50</td>   </tr>     <tr>     <td>5121657</td>     <td>orer name 4</td>     <td>40</td>     <td><input type="text" oid="5121657" name="bz[]"></td>     <td>1970-01-01 00:00:40</td>   </tr>    </table>  </body></html>


server.php 获取提交的备注与order id
<?php$bz = $_POST['bz'];foreach($bz as $key=>$val){    echo $key.'='.$val."\r\n";}?>



 辛苦了 非常感谢
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn