在Asp.Net MVC中用Ajax回调后台方法

在Asp.Net MVC中用Ajax回调后台方法基本格式:

var operData = ...; //传递的参数(action中定义的)

var type = ...;   //传递的参数(action中定义的)

$.ajax({
    url: "/..../....",
    type: "POST",
    data: { operData: operData, type: type },
    dataType: "json",
    success: function (result) {
      ....
    },
    error: function () {

      ....
    }
});

这里我们把需要传递的参数以 data 列表的形式展现出来,而不是直接在url中显示的附加,如:url: "/..../....?operData=....&type=...",这样就能很好的避免多语言以及特殊字符的问题,不妨一试。

原文地址:https://www.cnblogs.com/mingmingruyuedlut/p/3520696.html