I have a div id=title and input id=titleArea. I want to check if titleArea content exists before posting. I tried with getJSON but I understood I cannot get boolean values so I am getting string. emptu or not empty. The id is sent from script, I've checked that but no data is received
View script
<script> $("#title").on('change', function () { var id = $("#titleArea").val(); var msg = ""; $.getJSON(`?handler=CheckTitle&id=${id}`, (data) => { if (jQuery.isEmptyObject(data)) { $("#btnSubmit").attr("disabled", true) } else { $("#btnSubmit").attr("disabled", false) } }); }); </script>
JSON
public async Task<JsonResult> OnGetCheckTitle(string id) { var checkTitle = await _context.BlogDatas.Where(s => s.Title == id).Select(s => s.BID).SingleOrDefaultAsync(); return new JsonResult(checkTitle); }