Hi I am trying to return string value based on what I entered in txtInput, and will show in txtOutput
<input id="txtInput" class="form-control">
<input id="txtOutput" class="form-control">
below is my function
function GetOutput(output) {
var data = JSON.stringify({
output: output
});
$.get('GetOutput', data, function (data) {
$("#txtOutput").val(data);
}).fail(function (jqXHR, textStatus) {
alert(`Error = ${jqXHR.status} ${textStatus}`);
});
}
Below is my controller:
[HttpGet]
public JsonResult GetOutput(string output)
{
var po = db.Datas.SingleOrDefault(items => items.number== output);
return Json(po, JsonRequestBehavior.AllowGet);
}
I have an existing string : abc, but when I type in input abc it is not showing on the output but intead returning - Error = 200 parsererror
below is my code to display value in the output:
$("#txtInput").change(function () {
var a = $("#txtInput").val();
GetOutput(a)
});
Please help suggest where I went wrong on the above codes. Thank you in advanced!