Jquery 常用的代码---form ,ajax ,拼接表格

var path = '${pageContext.request.contextPath}/order/exportSale';
$('#form').attr("action", path).submit();

----------jquery Form 提交



$.ajax({
    url:'${pageContext.request.contextPath}/order/editSku-json',    
    type:'post',
    data:{"id":id,"sku":newsku},    
    async : false, //默认为true 异步    
    error:function(){
       alert('ajax error');    
    },
    success:function(data){
    var jsondata = eval("("+data+")");
    if(!jsondata.result){
    alert(jsondata.error);
    return;
    }
    --window.location.reload();
    }
});


---------------Ajax 提交


//批量操作
function test(){
var s ="";
$('#list_table [type="checkbox"]:checked').each(function(){
s+=$(this).val()+',';
});

var idList =  s.substring(0, s.length-1);
$.post('${contextPath }/order-package/back',
{idList : idList},
function(){
window.location.href="${contextPath }/order-package";
});
}
-------------------获取 ID 进行批量操作



function format(d){

var html = '<table>'
+ '<tr><th>名称</th><th>SKU</th><th>订单数量</th>'
+ '<th>包裹数量</th><th>出货数量</th><th>单价</th><th>包装规格</th>'
+ '<th>仓库</th></tr>'

$.ajax({
type : "post",
async: false,
url : "${contextPath }/order-package/packageItem",
data : {
      id : d.id,
  },
success : function(data) {

$.each(data, function(commentIndex, comment){
html += '<tr><th>'+comment.goodsName+'</th><th>'+comment.sku+'</th>
<th>'+comment.orderAmount+'</th>'+'<th>'+comment.packageAmount+'</th>    <th>'+comment.shipmentAmount+'</th><th>'+comment.price+'</th>  <th>'+comment.specifications+'</th>'+<th>'+comment.storeName+'</th></tr>'
});

   html += '</table>';
}
    });

   return html;
}

-----------返回data数据 拼接html 展示数据



你可能感兴趣的:(html,jquery,Ajax)