Dear all, could u help me how can this happen? I am newbie by the way
I want use java-script get data from SQL by ASHX Handler, but nothing come out
In ashx code :
*******************
using System;
using System.Web;
using System.Web.SessionState;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Data.Linq;
using System.Linq;
public class highChartm1 : IHttpHandler,IReadOnlySessionState {
public void ProcessRequest (HttpContext context) {
DataClassesDataContext dc = new DataClassesDataContext();
context.Response.ContentType = "text/plain";
var qr3 = (from x in dc.A_1_1
select new {x.CH1, x.CH2 }).Take(10);
string jsonString = JsonConvert.SerializeObject(qr3);
context.Response.Write(jsonString);
}
public bool IsReusable {
get {
return false;
}
}
}
In html javascript
*******************************************************
var options;
var mydata1 = [];
var mydata2 = [];
var TimeStamp = [];
$(document).ready(function () {
var url = "WeiAshx/highChartm1.ashx";
options = {
chart: {
renderTo: 'container',
type: 'spline'
},
credits: {
enabled: false
},
title: {
text: 'xxx'
},
series: [{
name: 'mydata1'
}, {
name: 'mydata2'
}]
};
$.ajax({
url: 'WeiAshx/highChartm1.ashx',
dataType: "json",
success: function (data) {
<big>>for (i in data) {
mydata1[i] = data[i].CH1;
mydata2[i] = data[i].CH2;
}
options.series[0].data = mydata1;
options.series[1].data = mydata2;</big>
var chart = new Highcharts.Chart(options);
},
cache: false
});
});}