为什么我的 ajax 呼叫不起作用?

Why my ajax call do not work?

我无法检测到为什么我的 ajax 调用不起作用。我正在尝试读取文本文件的内容,但它不起作用,问题是控制永远不会转到 .done(function(data))

 function makeCustomerTree()
    {
       // debugger
        alert('customertree');
        $.ajax(
            {
            url:"~/bootstrap/js/LiveMap/Ajax/JsonStringCarryingData/customer-tree-json.txt",
            data: {},
            type: "GET"
        }).done(function (data)
        {
            alert('done');
            $('#tree_loader').html('');
            tree = $.fn.zTree.init($("#customerTree"), setting, data);
            tree = $.fn.zTree.getZTreeObj("customerTree");
        }).fail(function (jqXHR)
        {
            alert('fail');
            $('#tree_loader').html('<font color="red">Unable to load.</font>');//jqXHR.responseText);
        });
    }

我的文件 customer-tree-json.txt 包含如下内容:

    [
    {
        "icon": "/static/tree/icons/user-20.png", 
        "pId": 7, 
        "id": 18, 
        "itemType": "lcustomer", 
        "name": "sachin bhatia"
    }, 
    {
        "itemType": "ldevice", 
        "pId": 18, 
        "name": "UK 06 AA 3840", 
        "open": true, 
        "id": "007060500336", 
        "icon": "/static/tree/icons/device-20.png"
    }
]

看到你的目录树后,相对 URL 必须是:

url:"/bootstrap/js/LiveMap/Ajax/JsonStringCarryingData/customer-tree-json.txt"