1. 程式人生 > >ajax的data傳參的兩種方式

ajax的data傳參的兩種方式

1.
/**
 * 訂單取消
 * @return {Boolean} 處理是否成功
 */
function orderCancel(orderId, commant){
	var flag = false;
	$.ajax({
	    type: "POST",
	    url: "../order/orderCancel.action", //orderModifyStatus
	    data: {"orderId":orderId,"commant":commant},
	    dataType:"json",
	    async:false,
	    cache:false,
	    success: function(data){
	    	var member = eval("("+data+")"); //包資料解析為json 格式                                                          
	        if(member.success=="true"){
        		flag = true;
	        }else if(member.success=="false") {
	        	alert(member.info);
	        }
		},
		error: function(json){
			alert("訂單取消異常,請重新整理後重試...");
		}
    });
    hidediv();
    return flag;
}

2.

data: "orderId=" + orderId + "&commant=" + commant