I am trying to get a JSON object back through an ajax call but am unable to. I don't understand what I am doing wrong here. Here is my controller:
public class RandomController : Controller
{
public ActionResult Index()
{
return View();
}
/// <summary>
/// Returns a JSON representation of a Content corresponding to the content ID passed in.
/// </summary>
/// <returns></returns>
public JsonResult GetStuff()
{
string x = "testing";
return Json(x, JsonRequestBehavior.AllowGet);
}
}
and here is my ajax request:
$(document).ready(function () {
$('#randombtn').click(function () {
$.ajax({
url: '/Random/GetStuff/',
success: function (data) {
alert(data);
}
});
});
});
and my button:
<input id="randombtn" type="button" value="Testing" />
Nothing happens when I click the button.