Skip to content Skip to sidebar Skip to footer

Show Response In The Div Tag

I'm calling a method by AJAX and I'm actually receiving a response, but I want to print that answer or show it in a div and I'm not doing that correctly.I want my response to be sh

Solution 1:

Firstly you need to change your GetData method to return Json:

[HttpGet]
public ActionResult GetData()
{
    var st = "kyo please help me u.u";
    return Json(new { success = true, message = st }, JsonRequestBehavior.AllowGet);
}

And then you can show the response in your div tag like this:

success: function (response) {
    $('#result').text(response.message);
},

Post a Comment for "Show Response In The Div Tag"