You do not need to specify a content-type , because it sets the type in which the server expects data, you do not send it, therefore you do not need to explicitly specify it, secondly, set dataType to json which is the format in which the client expects data from server. But I really doubt that this could be the cause of any errors.
Add an error callback to make sure that something went wrong on the way back
try
$.ajax({ type: "POST", url: "/Customer/GetDetails", dataType:'json', async: false,//WHY?? cache: false, success: function (data) { alert("success"); }, error:function(){ alert("something went wrong"); } });
Using
EDIT
mark your JsonResult with an HttpPost annotation, e.g.
[HttpPost] public JsonResult GetDetails() { CustomerDAL customer = new CustomerDAL(); IList<Customer> custList = customer.GetDetail(); return Json(custList); }
source share