I am using AJAX to call a method and I'm receiving a response successfully. However, I am struggling to display that response in a div
. I want the response to be shown in a #result
div element.
<div id="result"></div>
<input type="button" name="name" value="try" onclick="DepListQuery()" />
<script>
function DepListQuery() {
$.ajax({
type: 'GET',
url: '@Url.Action("GetData","Home")',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert(response);
},
failure: function (response) {
alert("something went wrong u.u");
}
});
}
</script>
Below is the code for my method:
[HttpGet]
public ActionResult GetData()
{
var st = "kyo please help me u.u";
return Content(st);
}