前端代码
$.ajax({
url: '/ashx/QuickQuery.ashx',
type: 'GET',
dataType: "json",
data: "fid=" + AFID + "&date1=" + date1 + "&date2=" + date2 + "",
success: function (json) {
//在百度地图上添加点
for (var i = 0; i < json[0].length; i++) {
var point = new BMap.Point(json[0][i].X, json[0][i].Y);
}
},
error: function (error) {
console.log(error);
$("#loading").hide();
alert("服务器忙...");
}
});
后台代码:
context.Response.ContentType = "text/plain";
string fid = context.Request.QueryString["fid"];
string date1 = context.Request.QueryString["date1"];
string date2 = context.Request.QueryString["date2"];
string constr = "Server=192.168.20.100;Uid=paishui;Pwd=tuyotech.paishui;Database=paishui";
MySqlConnection conn = new MySqlConnection(constr);
conn.Open();
MySqlCommand cmd = conn.CreateCommand();
if (date2 != "")
{
cmd.CommandText = "SELECT * from data where FID=" + fid + " and datetime >'" + date1 + "' and datetime
}
else
{
cmd.CommandText = "SELECT * from data where FID=" + fid + " and datetime >'" + date1 + "'";
}
MySqlDataAdapter adap = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
adap.Fill(ds);
string json = Newtonsoft.Json.JsonConvert.SerializeObject(ds.Tables);
conn.Close();
context.Response.Write(json);