jQuery UI Widgets › Forums › General Discussions › Layouts › Kanban › AJAX Call on itemMoved
This topic contains 5 replies, has 2 voices, and was last updated by Hristo 7 years, 4 months ago.
-
AuthorAJAX Call on itemMoved Posts
-
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 undefinedI 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
Hello mxh,
You could try to invoke the AJAX with
async: false.Best Regards,
Hristo HristovjQWidgets team
https://www.jqwidgets.comHey Hristo,
thanks for your reply. I tried that one again, but nothing – same error as before 🙁
Hello mxh,
Is there any error message?
You could add oneifstatement 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 HristovjQWidgets team
https://www.jqwidgets.comHey 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 undefinedThanks
Hello mxh,
I tested this again and the event is working fine.
I saw that you try to pass the wholeeventobject which is not very appropriate.
Try to send some simplified data in thedataobject of the AJAX.Best Regards,
Hristo HristovjQWidgets team
https://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.