0

我想从我的 json Web 服务中获取自动完成插件的数据源。但我无法将 json 字符串放入自动完成插件的数据源中。但是为什么我的网络服务中的数据源没有显示?

这是我的网络服务 json http://www.myservice.com/Service1.svc/list中显示的内容:

{"GetReportArResult":[
    {"FNCustomerCode":"RSK346","FnCustomerName":"KITCHEN LANGUAGE PTE LTD"},
    {"FNCustomerCode":"RSL117","FnCustomerName":"LOVELIFE VENTURES PTE LTD"},
    {"FNCustomerCode":"RSU386","FnCustomerName":"UDDERS PTE LTD"},
    {"FNCustomerCode":"RSB638","FnCustomerName":"BODY PLUS PTE LTD"},
    {"FNCustomerCode":"NTU042","FnCustomerName":"NTUC FAIRPRICE (339) -MARSILING MRT"},
    {"FNCustomerCode":"NTU108","FnCustomerName":"NTUC FAIRPRICE (335) -JURONG WEST"},
    {"FNCustomerCode":"RSI559","FnCustomerName":"IGGY'S PTE LTD"},
    {"FNCustomerCode":"RSG843","FnCustomerName":"GOLDEN DEVELOPMENT PTE LTD"},
    {"FNCustomerCode":"RSK583","FnCustomerName":"KOUFU PTE LTD (RASAPURA MASTER)"}
]}

这是我到目前为止所做的:

$("#ar_main").bind("pageshow", function(e) {
    $("#text_customer").autocomplete({
        target: $('#suggestions'),
        source: function(request, response) {
            $.ajax({
                type: "GET",
                contentType: "application/json; charset=utf-8",
                url: "http://www.myservice.com/Service1.svc/list",
                dataType: "json",
                data: {
                    term: request.term
                },
                success: function(data) {
                    response($.map(data.GetReportArResult, function(item) {
                        return {
                            label: item.FnCustomerName,
                            value: item.FnCustomerCode
                        };
                    }));
                }
            });
        },
        link: 'target.html?term=',
        minLength: 1
    });
});
4

0 回答 0