var data = [6];
data.push([10, Math.round(Math.random() * 100)]);
JqGraph Method
function redraw() {
$('#jqChart').jqChart({
title: { text: 'Change Series' },
border: { strokeStyle: '#6ba851' },
background: background,
legend: { visible: false },
axes: [
{
type: 'none',
location: 'bottom',
minimum: 0,
maximum: 6
},
{
type: 'linear',
location: 'left',
minimum: 0,
maximum: 100
}
],
series: [
{
type: 'line',
data: CallWebMethod() //REPLACING THIS WITH "data" WORKS
}
]
});
}
function CallWebMethod() {
$.ajax({
type: "POST",
url: "http://ift.tt/1OT63ik",
data: '{name: "" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
return response.d;
}
The problem with above code is that it does not work. If I replace data: CallWebMethod() with data and hard code it with wising push. It works.
WebMethod
**[System.Web.Services.WebMethod]
public static List<MyGenericType<dynamic>> CallWebMethod(string name)
{
List<MyGenericType<dynamic>> myList = new List<MyGenericType<dynamic>>();
myList.Add(new MyGenericType<dynamic>() { x = 10, y = 20 });
myList.Add(new MyGenericType<dynamic>() { x = 10, y = 20 });
myList.Add(new MyGenericType<dynamic>() { x = 10, y = 20 });
return myList;
}**
Aucun commentaire:
Enregistrer un commentaire