当前位置: 动力学知识库 > 问答 > 编程问答 >

jQuery Encrypted API - XML display

问题描述:

Is there a way to parse XML from an encrypted API via jQuery? Would I need to use ajax? Anyone have any examples? This is what I have:

http://www.mysite.com/net/[email protected]&

EncryptedPassword=XXXXX&EDI_Name=Generic\Products&

SELECT_Columns=p.ProductCode,pe.ProductPrice

This is the returned XML I would like to also return and parse into a table or something:

<?xml version="1.0" encoding="iso-8859-1"?>

<Export>

<Products_Joined>

<productcode>PRODUCT 1</productcode>

<productprice>1500</productprice>

</Products_Joined>

</Export>

网友答案:

Yes, assuming you have access to run javascript on the server, something like this:

var url = 'http://www.mysite.com/net/WebService.aspx?...';
$.ajax({
    type: 'GET',
    url: url,
    dataType: 'xml',
    success: function(xml) {
        var table = $('#mytable-id');
        $(xml).find('Products_Joined').each(function(){
            var product = $(this),
                code = product.find('productcode').text(),
                price = product.find('productprice').text();

            $('<tr />').append('<td>' + code + '</td>')
                .append('<td>' + price + '</td>')
                .appendTo(table);
        })
    }
});
分享给朋友:
您可能感兴趣的文章:
随机阅读: