Hi,
I have been trying to get a jqplot chart (a pie chart, in this instance) to work using a C# webservice as the data. I have tried returning data in all sorts of formats, but it is always being interpreted by JQuery as an object, and I cannot get it to transform into anything useful. The below works perfectly when I either hard code the data value, or pull it from a text file (for example [[['first', 8], ['second', 26], ['third', 12]]];), but obviously this isn't all that useful.
Here's the jquery:
$.ajax({
type: "POST",
url: "WEBSERVICEURL",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
plot1 = $.jqplot('pie1', JSON.parse(response.toString(), {
gridPadding: { top: 0, bottom: 38, left: 0, right: 0 },
seriesDefaults: { renderer: $.jqplot.PieRenderer, trendline: { show: false }, rendererOptions: { padding: 8, showDataLabels: true} },
legend: { show: true, placement: 'outside', rendererOptions: { numberRows: 1 }, location: 's', marginTop: '15px' }
});
},
failure: function (errMsg) {
$('#errorMessage').text(errMsg); //errorMessage is id of the div
}
});
I have tried the following return types in the webservice:
String, List<CustomObject>, Array, JSON String (formatted as per normal JSON response)
When I do an alert(response) in the JQuery above, I get <object>, and the errMsg just says "object XMLHTTPRequest".
I am new to jplot, and am slowly going mad trying to get this to work, so any advice would be gratefully received.