Response title
This is preview!
/* File Created: September 7, 2013 */
/// <reference path="jquery-2.0.3.min.js" />
/// <reference path="jquery.json-2.4.js" />
/// <reference path="jquery.jqplot.1.0.8r1250/dist/jquery.jqplot.min.js" />
$(document).ready(function () {
allCustomers = null; //Global
var encoded , customer , ok = false , customers = new Array() ;
$.ajax({
type: "POST",
url: "WebServiceToTabular_w_JSON.aspx/GetCustomers",
data: encoded,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
allCustomers = msg['d'];
jsonToHtmlTable(msg['d']);
ok = true;
},
error: function (msg) {
alert("Err : " + msg.d);
ok = false; }
});
});
var ajaxDataRenderer = function () {
return allCustomers;
};
function drawPlot() {
var plot = $.jqplot('chartdiv', jsonurl, { title: "AJAX JSON Data Renderer", dataRenderer: ajaxDataRenderer, dataRendererOptions: { unusedOptionalUrl: jsonurl } });
}
var jsonurl = "./jsondata.txt";
function jsonToHtmlTable(customers) {
var thing, encoded, id, name, title;
$.each(customers, function (index, element) {
thing = element;
encoded = $.toJSON(thing);
id = $.evalJSON(encoded).ID;
name = $.evalJSON(encoded).Name;
title = $.evalJSON(encoded).Title;
$('#customersTable tbody').append('<tr><td>' + id + '</td><td>' + name + '</td><td>' + title + '</td></tr>');
});
drawPlot();
}
© 2013 jQuery Foundation
Sponsored by and others.