2

If I dont any problem when myJson array have 1 object,but myJson array include 1 more than object I have problem that doesnot working post action.

        var items = [];
        $('.grid-stack-item.ui-draggable').each(function () {
            var $this = $(this);

            items.push({
                ID: $this.attr('data-ItemId'),
                x: $this.attr('data-gs-x'),
                y: $this.attr('data-gs-y'),
                Width: $this.attr('data-gs-width'),
                Height: $this.attr('data-gs-height'),
                UserDashboardId: $this.attr('data-dashboardid'),
                content: $('.grid-stack-item-content', $this).html()
            });
        }); 


        myJson = JSON.stringify(items)
        console.log(myJson);
        $.ajax({
            type: 'POST',
            url: '/Dashboard/SendItem/?json=' + myJson,
            success: function (message) {

            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert("jqXHR:" + jqXHR.status + " errorThrown: " + errorThrown);
            }
        });

error is 404 not found

1 Answer 1

1

try this

 var items = [];
        $('.grid-stack-item.ui-draggable').each(function () {
            var $this = $(this);

            items.push({
                ID: $this.attr('data-ItemId'),
                x: $this.attr('data-gs-x'),
                y: $this.attr('data-gs-y'),
                Width: $this.attr('data-gs-width'),
                Height: $this.attr('data-gs-height'),
                UserDashboardId: $this.attr('data-dashboardid'),
                content: $('.grid-stack-item-content', $this).html()
            });
        }); 


        myJson = JSON.stringify(items)
        console.log(myJson);
        $.ajax({
            type: 'POST',
            url: '/Dashboard/SendItem/',
            dataType: "json",
            data: myJson 
            contentType: "application/json",
            success: function (message) {

            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert("jqXHR:" + jqXHR.status + " errorThrown: " + errorThrown);
            }
        });
Sign up to request clarification or add additional context in comments.

1 Comment

you are welcome. you should mark this as the correct answer if it works for you

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.