标签:
1 <div> 2 <table> 3 <tr> 4 <th>状态</th> 5 <th>信息</th> 6 </tr> 7 <tr> 8 <td>00</td> 9 <td>显示信息</td> 10 </tr> 11 </table> 12 </div>
<input type="submit" name="xx" value="提交">
js部分:
1 <script src="jquery.js"></script> 2 <script> 3 $(function(){ 4 $(‘input[name="xx"]‘).click(function(){ 5 alert(‘12‘); 6 $.post(‘vv.php‘,{a:‘yy‘},function(msg){ 7 var x = eval(‘(‘+msg+‘)‘); 8 $.each(x,function(i,m){ 9 $(‘table‘).append(‘<tr><td>‘+m.status+‘</td><td>‘+m.msg+‘</td></tr>‘); 10 }),‘json‘ 11 }) 12 }) 13 }) 14 </script>
php部分:
1 <?php 2 $a = !empty($_POST[‘a‘])?$_POST[‘a‘]:0; 3 if($a==‘yy‘){ 4 $arr = array( 5 array(‘status‘ => 0, ‘msg‘ => ‘未知错误‘), 6 array(‘status‘ => 1, ‘msg‘ => ‘未知错误22‘) 7 ); 8 echo json_encode($arr); 9 } 10 ?>
标签:
原文地址:http://www.cnblogs.com/lola/p/5632604.html