do like this
return Json(data, JsonRequestBehavior.AllowGet);
explanation : function returns the type of JsonResult, which is inherited by ActionResult.
JsonRequestBehavior.AllowGet
:
From this Answer why-is-jsonrequestbehavior-needed
This is to protect against a very specific attack with JSON requests
that return data using HTTP GET.
Basically, if your action method does not return sensitive data, then
it should be safe to allow the get.
However, MVC puts this in with DenyGet as the default to protect you
against this attack. It makes you consider the implications of what
data you are exposing, before you decide to expose it over HTTP GET
if you are planning to redirect based on json data
return Json(new
{
redirectUrl = Url.Action("AccountMyProducts", "Account"),
isredirection= true
});
in Jquery success call back function, do like this
$.ajax({
.... //some other stuffs including url, type, content type.
//then for success function.
success: function(json) {
if (json.isredirection) {
window.location.href = json.redirectUrl;
}
}
});