JS前端调用后台方法

//JS前端代码
function
Exportqmdltb() { var areavalue= GetQmdltmValue(); $.ajax({ type: "post", dataType: "text", url: "./GisUtility/GeometryHelper.ashx",//文件路径 data: { "action": "exportqmdltb", "areavalue": areavalue }, beforeSend: function () { }, complete: function () { }, success: function (data) { alert("导出成功:"+data); }, error: function (ex) { alert("导出失败:" + ex); } }); }
 //GeometryHelper.ashx文件代码(后台代码)
public void ProcessRequest(HttpContext context)
        {
            string pGeoJson = string.Empty;

            if (context.Request.Params["action"] == "exportqmdltb")//
            {
                string areavalue = context.Request.Params["areavalue"];
                string tile = "面积统计表";
                pGeoJson= CommUtility.ExportQmdltb2Excel(tile,areavalue);//要调用的后台方法
            }
            context.Response.Write(pGeoJson);//返回到前端的结果

        }
多看一行书,就少写一行代码,记录点滴,用心生活。
原文地址:https://www.cnblogs.com/aegisada/p/3673492.html