'Action returns Status Code 204 but, AJAX success function doesn't execute
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
Solution 1:[1]
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('');
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
