Hi all: I´m new to JQuery, so maybe i´m doing something badly. I have a previously defined javascript tree, i´m rewriting the code to use ajax.
This tree has a function beforedelete: function(node) If this function returns false, no node will be deleted in user interface. If sends true, the node is deleted. I need to use $.get to decide if the tree node is deletable or not, so i write this code: beforedelete: function(NODE) // before delete - should return true | false { isOK = false; $.get("/isdeletable", { 'node': [ NODE ]} , function (data) { if (data == 1) isOK = true; else isOK = false; } ); return isOK; } isOK is a global variable. I can get the result (for the moment simple 0 or 1) from the server side script. It works correctly. The problem is that beforedelete finished his work before i get the data from the server (i discover it putting an alert before the return). So it seems that this method is not valid, but i need to analyze the answer and that beforedelete sends the correct value. What is the way to do it? Thank you in advance.