Reputation: 61
I am trying to use Highcharts with an external server that returns a JSON file but I cannot get the returning file to bind to the chart. I am developing the application in ASP.NET MVC
My attempt at the code is here: http://jsfiddle.net/Q6ngj/2/
jQuery.ajax({
url: urlM4AirTemp,
dataType: 'jsonp',
cache: true,
jsonp: false,
jsonpCallback: 'ourCallbackM4AirTemp'}).done(function (airTempData) {
var msg = airTempData.table.rows;
var intYr;
var intMonth;
var intDay;
var intHour;
var intMin;
var intSec;
jQuery.each(msg,function(i,value){
intYr = value[0].substring(0,4);
intMonth = value[0].substring(5,7)-1;
intDay = value[0].substring(8,10);
intHour = value[0].substring(11,13);
intMin = value[0].substring(14,16);
intSec = value[0].substring(17,19);
var d = new Date(intYr,intMonth,intDay, intHour,intMin, intSec);
d =d.toUTCString();
d=Date.parse(d);
airTemp.push([d,value[1]]);
});
//Load up Graph
options.series[0].data = airTemp;
chart = new Highcharts.Chart(options);
});
};
Is ajax the correct method to call here or should I be using getJSON?
Upvotes: 0
Views: 184
Reputation: 45079
Two problems I see in jsFiddle:
jsonpCallback: ('ourCallbackM4AirTemp');
-> remove ;
, it breaks js codeUpvotes: 0
Reputation: 2495
In first line (script at jsfiddle):
(function(){
In last:
})();
And whole json in remote file should be wrapped in ourCallbackM4AirTemp(
and );
.
Upvotes: 1