Click here to Skip to main content
16,004,452 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 :
*******************
C#
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(); //linq to sql clsaa
        context.Response.ContentType = "text/plain";
        var qr3 = (from x in dc.A_1_1
                   select new {x.CH1, x.CH2 }).Take(10);          //sent to client side data
        string jsonString = JsonConvert.SerializeObject(qr3); //using Json.net
        context.Response.Write(jsonString);
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }
}


In html javascript
*******************************************************
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
    });
});}
Posted
Updated 24-Feb-14 21:58pm
v3
Comments
ZurdoDev 25-Feb-14 7:38am    
Put a breakpoint and find out what is happening.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900