Dr.Ajay Kashyap

Dr.Ajay Kashyap

  • NA
  • 521
  • 283.7k

event.preventDefault not working when condition true

Feb 9 2017 4:01 AM
when condition false event.preventDefault working but when condition true event.preventDefault not submit page.
 
This Is My Code:- 
 
<script>
$("#category").on('submit', function (event) {
event.preventDefault ? event.preventDefault() : event.returnValue = false;
var url = '@Url.Action("CheckCategory_Name", "CategoryAndSubCategory")';
$.getJSON(url, { Category1: Category1, Category2: Category2, Category3: Category3, Category4: Category4, Category5: Category5 }, function (data) {
debugger;
if (data.isDuplicate != true) {
$("#category").submit();
return true;
}
else {
swal("The Category Name Is Already Exist");
return false;
}
});
 
});
</script>
 

Answers (7)