My controller is correctly returning new HttpStatusCodeResult(204)
(checked using debugging), but the success function is not triggered. I just want to reset a text field after I've submitted something.
Ajax:
$(document).ready(function () {
$("#offersubmit").click(function (e) {
$.validator.unobtrusive.parse($('offerForm'));
if ($(this).valid()) {
var valdata = $("#offerForm").serialize();
$.ajax({
url: "/Product/MakeOffer",
type: "POST",
dataType: 'json',
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
data: valdata,
success: $(document).ready(function () {
alert("AAA");
$('#offerText').val('');
})
})
}
});
});
Also tried with alert()
and it didn't show anything. Any help would be appreciated
You need to remove the $(document).ready(.. code
success: $(document).ready(function () {
alert("AAA");
$('#offerText').val('');
})
should be
success: function(data) {
alert("AAA");
$('#offerText').val('');
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.