hitting controller and returning data while debugging but in js>>Ajax call>>success is not hitting
repository
public FGMOQMapping GetFGMOQMappingAutoSuggest(long loginId)
{
FGMOQMapping fGMOQMapping = new FGMOQMapping();
DynamicParameters parameters = new DynamicParameters();
parameters.Add("LoginId", loginId);
using (var multi = con.QueryMultiple("usp_FGMOQMapping_GetList_AutoSuggest", parameters, commandType: CommandType.StoredProcedure)) {
fGMOQMapping.FGList=multi.Read<FGMOQMapping>().ToList();
fGMOQMapping.SFGList = multi.Read<FGMOQMapping>().ToList();
}
return fGMOQMapping;
}
controller
public JsonResult NPDAutoSuggest()
{
NPD npdObject = new NPD();
//npdObject.FGList = _purchaseOrderRepository.GetFGMOQMappingList(0, Convert.ToInt64(Session["UserId"]));
FGMOQMapping fGMOQMapping = new FGMOQMapping();
fGMOQMapping= _purchaseOrderRepository.GetFGMOQMappingAutoSuggest(Convert.ToInt64(Session["UserId"]));
npdObject.FGList = fGMOQMapping.FGList;
npdObject.SFGList = fGMOQMapping.SFGList;
npdObject.PlantList = _plantRepository.GetPlantList(0, "", "", Convert.ToInt64(Session["UserId"]));
var Jsondata = JsonConvert.SerializeObject(npdObject);
return Json(Jsondata, JsonRequestBehavior.AllowGet);
}
ajax , js
$.ajax({
url: ROOT + "PurchaseOrder/NPDAutoSuggest",
type: 'POST',
datatype:'JSON',
success: function (result) {
AutoData = JSON.parse(result);
},
error: function (result) {
console.log(result);
alert("not");
}
});
ajax is hitting error block,
please help me out to solve this
2
Answers
hello everything was fine here . but json limit exceeded so i used return in different way in controller (if You have large amount of data we may get this issue so use this return kind)
You create an
anonymous object
to send to the ajax success method. like thisreturn Json(new { data = Jsondata }, JsonRequestBehavior.AllowGet);
And in ajax get this
anonymous object