This is a migrated thread and some comments may be shown as answers.

Error: “Maximum call stack size exceed” AJAX calling WebMethod

2 Answers 2375 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 1
Bill asked on 05 Jul 2016, 03:44 PM

I'm trying to send a GridDataItem object that's retrieved from the selected row of a RadGrid.
But I'm getting an Uncaught RangeError: Maximum call stack size exceeded error when I make this AJAX call.

When I run the code, my AJAX success fires, but the breakpoint I have on the WebMethod never hits. After this, the pages freezes momentarily, then I get the error I mentioned above.

    $(document).ready(function () {
        $('#<%=btnTransferIn.ClientID%>').on('click', function () {
            var grid = $find("<%= gridStudents.ClientID %>"); //Returns an Object
            var gridSelItems = grid.get_selectedItems(); //Returns Array
            var selectedItem = gridSelItems[0]; //Returns an Object

            AjaxTransfer(gridSelItems);
        });
    });

    function AjaxTransfer(selectedItem) {
        $.ajax({
            type: "POST",
            url: "GradeSheet2.aspx/btnTransferIn_Click",
            data: { 'gsi': selectedItem },
            dataType: "json",
            contentType: "application/json; charset=utf-8",
            success: alert('Complete')
        })
    }

This is the WebMethod I want to call:

    [System.Web.Services.WebMethod]
    public static string btnTransferIn_Click(GridDataItem gsi)
    {
        return "Done";
    }

I noticed, if I change the WebMethod's parameter to a string and I pass in a string instead of an object, it works.  So it seems like there's something wrong with the object or the way I'm passing it to the WebMethod.

I checked the object in the console before I make the AJAX call and I think it looks alright.. Although, I don't have a high understanding of all of it.

http://i.stack.imgur.com/TUv8C.png

Please let me know if more information is needed.  

Thanks in advance! 

2 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 06 Jul 2016, 10:30 AM
Hi Bill,

You could run it in IE/Edge in debug mode to see exactly where the exception is happening.

It is most probably because of selectedItem is object that have ._owner property. The _owner is Grid object which have items property that contain the item. So in general you can not pass the item as object inside your query.

If you need to send the data key for this item, you could add the field into ClientDataKeyNames property of the grid.
Then you could do 

data: { 'gsi': selectedItem._data.yourField }

Or if you want to sent the index:
data: { 'gsi': selectedItem._itemIndex } 
or
data: { 'gsi': selectedItem._itemIndexHierarchical }


Regards,
Vasil
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Ramesh
Top achievements
Rank 1
answered on 28 Aug 2017, 12:49 PM
UI for ASP.NET AJAX Hi I am using telerik:RadEditor control when i try to load the file into editor window i am getting "Error while executing filter CleanAttributesFilter - RangeError: Maximum call stack size exceeded" error. im getting this error oly my file size is more then 3MB HTML text. Can some one help me out how to resolve this ?
Tags
Ajax
Asked by
Bill
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Ramesh
Top achievements
Rank 1
Share this question
or