- Back to Home »
- MVC JsonReult with Ajax
function LoadItemsByCategoryID() {
var category_id = $("#drpCategory").val();
$.ajax({
url: "Student/LoadItemsByCategoryID", // Current Page, Method (Controller/JsonResult)
data: JSON.stringify({ categoryID: category_id }),
type: "POST", // data has to be POSTed
contentType: "application/json", // posting JSON content
dataType: "JSON", // type of data is JSON (must be upper case!)
// timeout: 10000, // AJAX timeout
success: function (response) {
var models = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
$("#drpItem").empty();
for (var i = 0; i < response.length; i++) {
$("#drpItem").append("");
}
},
error: function (response) {
}
});
}