You will have to copy the jquery extension to convert a form to json object
(function() {
$.fn.serializeObject = function() {
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
})(jQuery)
and include json2.js library to add JSON.stringify()
support for legacy browsers
Then change you ajax to
$.ajax({
url : '',
type: 'POST',
contentType : 'application/json',
data : JSON.stringify($('form').serializeObject()),
....
})
In your case
$('#frm').submit(function() {
postJSON('@Url.Action("Create", "District")', JSON.stringify($('form').serializeObject()),
function(result) {
alert(result.Message);
if (result.Success) {
window.location = '@Url.Action("Index", "District")';
}
});
return false;
});