如何在AciTree jQuery插件的Ajax调用中添加自定义querystring参数

how to add a custom querystring parameter on Ajax call of AciTree jQuery plugin

本文关键字:调用 添加 自定义 参数 querystring Ajax AciTree jQuery 插件      更新时间:2023-09-26

我正在使用jQueryI想要发送一个自定义的querystring参数以及node_id,例如_type,这是在json中,如下所示

[{
    "id":"2",    
    "label":"Title for folder",    
    "branch":[],    
    "inode":true,    
    "open":false,    
    "icon":"folder",    
    "_type":"library"
}]

我正在尝试使用ajaxhook,如下所示

ajaxHook: function (item, settings) {
    // the default implementation changes the URL by adding the item ID at the end    
    alert(this.itemData._type);    
    settings.url += (item ? this.getId(item) : '');    
}

我无法使用此方法获得我的自定义属性_type

this。itemData是一个数组,因此,您可以对它进行循环,或者执行如下操作:

alert(this.itemData[0]._type);

正确的做法如下:

  ajaxHook: function (item, settings) {
                    // the default implementation changes the URL by adding the item ID at the end
                    if (item != null) {
                        var ItemData = this.itemData(item);
                        settings.url += (item ? this.getId(item) : '') + '&type=' + ItemData._type;
                    }
                },