weixin_33708432 2015-06-01 06:57 采纳率: 0%
浏览 113

为什么我的ajax调用不起作用?

I am not able to detect why my ajax call do not work. I am trying to read the contents of text file but it do not work, The problem is control never go to .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);
        });
    }

Where my file customer-tree-json.txt contains the contents like this:

    [
    {
        "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"
    }
]
  • 写回答

1条回答 默认 最新

  • 七度&光 2015-06-02 17:10
    关注

    After seeing your directory tree, relative URL has to be :

    url:"/https/ask.csdn.net/bootstrap/js/LiveMap/Ajax/JsonStringCarryingData/customer-tree-json.txt"
    
    评论

报告相同问题?