0

I am populating a grid in JavaScript by calling a webmethod(return json dataset. Dataset contains datatable). Grid is successfully filling when there is less than 100 rows. If there is more rows , it is not returning to Success method of ajax call.

Already tested with breakpoint, break point is coming till return statement in webmethod.

AJAX call:

$.ajax({ type: "POST", url: 'CopyofItemInquiries.aspx/GetUPCDetails', data: JSON.stringify({ UPCCollection: UPCCol, UPCLike: UPCLike, UPCRangeFrom: RangeFrom, UPCRangeTo: RangeTo, Filter: FilterVal }), contentType: "application/json; charset=utf-8", dataType: "json", success: function (Result) { var myjsongrid = $.parseJSON(Result.d); } });

Web method:

[WebMethod] [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json, UriTemplate = "json")] public static string GetUPCDetails(List UPCCollection, String UPCLike, String UPCRangeFrom, String UPCRangeTo,String Filter) { System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); Dictionary dic_SaveUser = new Dictionary();

    var xml = new XElement("ROOT", UPCCollection.Select(x => new XElement("UPCLIST",
                                            new XAttribute("UPC", x))));


    dic_SaveUser.Add("@User_ID", HttpContext.Current.Session["FT_username"]);

    DataSet dt_DataSet = new DataSet("dt_DataSet");
    dt_DataSet = DbAccessModule.getDataTableStoredProcedureForMultipleResultSet((SqlConnection)HttpContext.Current.Session["lt_AppConn"], "sp_UPC_Details", dic_SaveUser);

    HttpContext.Current.Session["VendorDetails"] = dt_DataSet.Tables[1];

    return JsonConvert.SerializeObject(dt_DataSet);
}
TG Nath
  • 11
  • 7
  • Can you add an error callback, something like this: error: function () {console.log("error"); }, double check you're not getting an error? – vscoder Apr 25 '19 at 16:21
  • Thank you for you response. I added an error method like this error: function (jqXHR, exception) { } and it returned jqXHR.status == 500 . I think its Internal Server Error [500] . How can I find the what the error could be? – TG Nath Apr 25 '19 at 17:55
  • Wrap the WebMethod code in a try-catch would be my first guess, place a break point on the exception. Also, use the debugger to step through the code on the server side and see if it fails in the code. – vscoder Apr 25 '19 at 18:34
  • Also, you might want to check out this SO question, the JSON payload might be too large - https://stackoverflow.com/questions/1151987/can-i-set-an-unlimited-length-for-maxjsonlength-in-web-config – vscoder Apr 25 '19 at 18:36
  • Thank you so much. My problem solved when I set in web config – TG Nath Apr 25 '19 at 20:50
  • No problem good luck with your project – vscoder Apr 25 '19 at 21:02

0 Answers0