Analysis of two ways of data parameter transfer in AJAX

Time:2020-10-31

This paper describes two ways of data transfer in Ajax. For your reference, the details are as follows:

1. Post mode:

/**
 *Order cancellation
 *Is the @ return {Boolean} process successful
 */
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 + ")"); // the package data is parsed into JSON format
      if(member.success=="true"){
        flag = true;
      }else if(member.success=="false") {
        alert(member.info);
      }
    },
    error: function(json){
      Alert ("order cancellation exception, please refresh and try again...);
    }
  });
  hidediv();
  return flag;
}

2. Get method:

Copy codeThe code is as follows:
data: “orderId=” + orderId + “&commant=” + commant

I hope this article will be helpful to everyone’s Ajax programming.