<script type="text/javascript">
//Add New Item by Web API
$("#Save").click(function () {
//Making complex type object
Price: $("#Price").val(),
Category: $("#Category").val()
if (Product.Name != "" && Product.Price != "" && Product.Category != "") {
//Convert javascript object to JSON object
var DTO = JSON.stringify(Product);
url: 'api/product', //calling Web API controller product
contentType: 'application/json; charset=utf-8',
success: function (data) {
function (xhr, textStatus, err) {
alert('Please Enter All the Values !!');
<label for="name">Name</label>
<input type="text" id="Name" title="Name" />
<label for="category">Category</label>
<input type="text" id="Category" title="Category" />
<label for="price">Price</label>
<input type="text" id="Price" title="Price" />
<button id="Save">Save</button>
<button id="Reset">Reset</button>