I am developing an application that uses JS Tree with json data and ajax per the documentation at http://www.jstree.com/documentation/json_data.
$("#tree).jstree({
"json_data": {
"ajax": { ... }
} ....
});
There are also other jquery ajax calls being made elsewhere in the document. Right now, the tree makes its ajax calls within its own name space so there are no conflicts with the other ajax functions. Because of issues with the server that answers the ajax calls, I need to redirect the tree’s ajax calls through the common ajax handler the rest of the document uses and then have that handler return the data back to the tree.
Can anyone suggest how to redirect the tree’s calls to another function and set up the callback to return the data back to the tree? Thanks!
I will give you an idea. Not sure if it will fit your requirements, and probably you will need to work it out a little bit more, but it’s somehow close to what I’ve understood from your question:
The json_data plugin, as stated in the documentation, is pretty much the same as the jQuery ajax settings object
With this in mind, you can redirect/conduct the ajax query to a custom function making use of the
beforeSend() callback functionAnd define a custom function where you can take over the XHR object and adjust it to your needs:
What I’m doing here is setting up the URL, the request type (GET) and a couple of parameters that you could want to pass to the custom function as another object, ot whatever is more convenient (for instance you will want the parent_id to be variable).
You will need to return false in this custom function so the first caller request gets canceled.
Please let me know if it’s helpful.