JavaScript脚本访问后台服务实例

论坛 期权论坛 脚本     
匿名技术用户   2020-12-30 18:34   11   0

js访问后台服务实例


前端代码:

function GetHeatMapFunc()
{
var s_time = "2017-11-12";
var s_hour = 8;
var e_time = "2017-11-13";
var e_hour = 8;
$("#map").css("cursor", "wait");

var urlStr = encodeURI("XXXXXX.ashx?method=ssyq&oper=ToDayRainInfo&Ale=" + s_time + "&oge=" + s_hour + "&phe=" + e_time + "&bna=" + e_hour + "&vins=1&" + Math.random());
$.ajax({
type: "get",
contentType: "application/json;charset=UTF-8",
url: urlStr,
success: success,
error: error
});
}


function success(data)
{
S_rainheatmap = data;
......
}


function error()
{
alert("heatmap request error!");
}



后台服务代码

public class XXXXXX : IHttpHandler {


public struct ParaStrObj
{
public string paraStr { get; set; }
}

//js通过ajax传递参数至该模块
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
///Online Analysis Func. isoline,isomultipolygon and heatmap of jiangsu,witch by some args.
string method = System.Web.HttpContext.Current.Request["method"].ToString();
//Args: time range and rank of rain
string s_d = System.Web.HttpContext.Current.Request["Ale"].ToString();
string s_h = System.Web.HttpContext.Current.Request["oge"].ToString();
string e_d = System.Web.HttpContext.Current.Request["phe"].ToString();
string e_h = System.Web.HttpContext.Current.Request["bna"].ToString();
string cls = System.Web.HttpContext.Current.Request["vins"].ToString();


string begin_date = s_d + " " + s_h + ":00";
string end_date = e_d + " " + e_h + ":00";
string rank = cls;
//根据传参处理相关数据请求
res = JS_OnlineAnalyse(method, begin_date, end_date, rank, context);


context.Response.Write(res);
}


分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP