0

I have a list object. I want to pass my list view to controller with Ajax function My code like :

    function Save()
    {
        debugger;
        if(!ValidateInput()) return;
        var oRecipe=RefreshObject();
        var oRecipeDetails=$('#tblRecipeDetail').datagrid('getRows');
        var postData = $.toJSON(oRecipe);
        var mydetailobj= $.toJSON(oRecipeDetails);
//        postData="Hello world!!!!!!! Faruk";
        //return;
        $.ajax({
            type: "GET",
            dataType: "json",
            url: '/Recipe/Save',
            data: { myjsondata : postData, jsondetailobject : mydetailobj},
            contentType: "application/json; charset=utf-8",
            success: function (data) {
                debugger;
                oRecipe = jQuery.parseJSON(data);
                if (oRecipe.ErrorMessage == '' || oRecipe.ErrorMessage == null) {
                    alert("Data Saved sucessfully");
                    window.returnValue = oRecipe;
                    window.close();
                }
                else {
                    alert(oRecipe.ErrorMessage);
                }
            },
            error: function (xhr, status, error) {
                alert(error);
            }

        });
    }

Normally my code run successfully if my list length <=3/4 but when my list length >4 here a problem arise. I could not find out what is bug? please any one suggest me

Note : Here i try to pass by list object convert to JSON data

5
  • please give a example link Commented Feb 18, 2013 at 4:06
  • stackoverflow.com/questions/14927576/… Commented Feb 18, 2013 at 4:10
  • need any special jquery reference? Commented Feb 18, 2013 at 4:19
  • I think its pretty old Commented Feb 18, 2013 at 4:19
  • i get a message like JSON Undefine Commented Feb 18, 2013 at 4:26

1 Answer 1

0

Why type "GET"? It is obvious that you want to post your data back to the controller. Change it to "POST" and try.

$.ajax({
            type: "POST",
            dataType: "json",
            ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.