santhosh

santhosh

  • NA
  • 12
  • 696

Unable to disable and enable button based on condition

Jul 16 2019 9:26 AM
  1. [HttpGet]  
  2. public ActionResult ButtonValidation(int? id)  
  3. {  
  4. var result = false;  
  5. var items = db.VW_PLAN_TY_STG.Where(x => x.JOB_BTCH_ID == id ).FirstOrDefault();  
  6. if (items.STAT_DESC == "Error")  
  7. {  
  8. result = true;  
  9. }  
  10. return Json(new { emailSent = result });  
  11. }  
  1. this.btnvalidate = function(jobBatchId) {  
  2. var url = '@Url.Action("ButtonValidation")/' + jobBatchId;  
  3. var promise = $.ajax({  
  4. url: url,  
  5. type: 'GET',  
  6. //data: jobBatchId,  
  7. dataType: 'JSON',  
  8. processData: true,  
  9. contentType: "application/json; charset=UTF-8",  
  10. cache: false,  
  11. success: function (data) {  
  12. if (data.emailSent == 'true') {  
  13. $('#btnSubmit').prop('disabled'true);  
  14. else {  
  15. $('#btnSubmit').prop('disabled'false);  
  16. }  
  17. }  
  18. });

Answers (2)