I recommend the opposite, have your jQuery code call the server-side via ASP.NET AJAX Page Methods, like this:
$(document).ready(function() {
// For example's sake, this will ask the database for
// data upon the DOM being loaded
$.ajax({
type: "POST",
url: "PageName.aspx/GetPieChartData",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(result) {
// Plot result data returned from AJAX call to server
$.plot('#placeholder', result.d, {
series: {
pie: {
show: true
}
}
});
}
});
});
Note: You will need to rename PageName.aspx to your actual .aspx page name.
Code-behind:
[WebMethod]
public static string GetPieChartData()
{
// Go to database and retrieve pie chart data
string data = GetPieChartDataFromDatabase();
return data;
}
Note: ASP.NET AJAX Page Methods automatically JSON-encode the returned data, so there is no serialization call needed on the server-side. Also, note ASP.NET AJAX Page Methods must be static, as they have no interaction with the actual page class itself.