I am trying to post some data with jQuery Ajax, but the parameters in my Ajax method are null.
This is simple test to send data:
var dataPost = { ti
We don't need the contentType: 'application/json; charset=utf-8', and $.toJSON
Here is the code makes me happy!
$(function () {
$("#btnSumbit").click(function () {
$('#results').hide();
$('#loadingmessage').show();
var a = $("#query").val();
$.ajax({
type: "POST",
url: "/Search/Index",
data: ({ query: a }),
datatype: "json",
success: function (data) {
$('#results').empty();
for (var i = 0; i < data.length; i++) {
var div = "" + data[i].Name + "";
$("#results").append(div);
}
$('#loadingmessage').hide();
$('#results').show();
},
failure: function (errMsg) {
$('#loadingmessage').hide();
alert(errMsg);
}
});
});
});