HTML and CSS Reference
In-Depth Information
url: '/Chart/SaveChart',
data: finalData,
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (result) {
alert(result);
}
});
});
The code needs to pass a complex JSON object from the client side to the server because the
SaveChart() method takes three parameters. Additionally, one of the parameters is an array of ChartDetail
objects. The code from Listing 4-29 constructs a JSON object ( (finalData) ) by gathering various pieces of
information (such as the chart title and sector details). The jQuery $.ajax() method then makes a POST
request to the SaveChart() method and passes the JSON object along with the call. The success function
displays the returned message from the server in an alert box.
Figure 4-26 shows a sample run of the application.
Figure 4-26. Successful run of the application
As you can see if you successfully save the chart on the server, a success message is displayed in an
alert box. You can verify the save operation by checking for the existence of the data in the ChartMaster and
ChartDetails tables.
 
Search WWH ::




Custom Search