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:"/bootstrap/js/LiveMap/Ajax/JsonStringCarryingData/customer-tree-json.txt"
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度