jQuery UI Widgets Forums Layouts Kanban AJAX Call on itemMoved

This topic contains 5 replies, has 2 voices, and was last updated by  Hristo 3 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • AJAX Call on itemMoved #104350

    mxh
    Participant

    Hi,
    im trying to execute an AJAX function when an kanban item is moved, to do some server-side actions then. My code looks like this:

    $('#kanban').on('itemMoved', function (event) {
      $.ajax({
        type: "POST",
        url: "create.php",
        data: event
      });
    });

    And I’m facing this error:

    Uncaught TypeError: Cannot read property 'target' of undefined

    I guess the reason is $.ajax fires before the object is resolved, but am not deep enough into those concepts to make it work.

    Any ideas or approaches?

    Thanks

    AJAX Call on itemMoved #104386

    Hristo
    Participant

    Hello mxh,

    You could try to invoke the AJAX with async: false.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com

    AJAX Call on itemMoved #104387

    mxh
    Participant

    Hey Hristo,

    thanks for your reply. I tried that one again, but nothing – same error as before 🙁

    AJAX Call on itemMoved #104394

    Hristo
    Participant

    Hello mxh,

    Is there any error message?
    You could add one if statement to check does such ‘event’ object exist.
    If still did not handle this issue, please, provide us with simplified source code to try to reproduce it.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com

    AJAX Call on itemMoved #104401

    mxh
    Participant

    Hey Hristo,

    I added the if statement, but same problem. Ive been trying to make this work for more than 4 days and im slowly running out of ideas.
    You can reproduce it using this code (url doesnt really matter…):

    $(document).ready(function () {
            $('#kanban').on('itemMoved', function (event) {
                        $.ajax({
                            type: "POST",
                            url: "create.php",
                            data: event
                        });
            });
    });

    And the error again:

    Uncaught TypeError: Cannot read property 'target' of undefined

    Thanks

    AJAX Call on itemMoved #104491

    Hristo
    Participant

    Hello mxh,

    I tested this again and the event is working fine.
    I saw that you try to pass the whole event object which is not very appropriate.
    Try to send some simplified data in the data object of the AJAX.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.