Maison > Article > développement back-end > ajax 批量提交解决方案
ajax 批量提交
每一行是一条订单 现在给订单加备注 不知道怎么能实现批量提交 求思路
------解决方案--------------------
client.html
<br /><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><br /><html><br /> <head><br /> <meta http-equiv="content-type" content="text/html; charset=utf-8"><br /> <title> client post</title><br /> <script src="//code.jquery.com/jquery-1.11.0.min.js"></script><br /> </head><br /><br /> <body><br /> <script type="text/javascript"><br /> function fsubmit(){<br /><br /> var bzArray = '';<br /><br /> $("input[name='bz[]']").each(function(){<br /> bzArray+= "&bz[" + $(this).attr('oid') + "]="+$(this).val(); <br /> });<br /><br /> $.post("server.php", bzArray,function(ret){<br /> alert(ret);<br /> });<br /> }<br /> </script><br /><br /> <input type="button" value="批量提交" onclick="fsubmit()"><br /> <table><br /> <tr><br /> <td>编号</td><br /> <td>名称</td><br /> <td>价格</td><br /> <td>备注</td><br /> <td>时间</td><br /> </tr><br /> <tr><br /> <td>5121653</td><br /> <td>orer name 1</td><br /> <td>20</td><br /> <td><input type="text" oid="5121653" name="bz[]"></td><br /> <td>1970-01-01 00:00:20</td><br /> </tr><br /> <tr><br /> <td>5121654</td><br /> <td>orer name 2</td><br /> <td>30</td><br /> <td><input type="text" oid="5121654" name="bz[]"></td><br /> <td>1970-01-01 00:00:30</td><br /> </tr><br /> <tr><br /> <td>5121655</td><br /> <td>orer name 3</td><br /> <td>50</td><br /> <td><input type="text" oid="5121655" name="bz[]"></td><br /> <td>1970-01-01 00:00:50</td><br /> </tr> <br /> <tr><br /> <td>5121657</td><br /> <td>orer name 4</td><br /> <td>40</td><br /> <td><input type="text" oid="5121657" name="bz[]"></td><br /> <td>1970-01-01 00:00:40</td><br /> </tr> <br /> </table><br /> <br /> </body><br /></html><br /><br />
<br /><?php<br />$bz = $_POST['bz'];<br /><br />foreach($bz as $key=>$val){<br /> echo $key.'='.$val."\r\n";<br />}<br /><br />?><br />