Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 以html格式检索表格式的xml数据_Jquery_Angularjs_Ajax_Xml - Fatal编程技术网

Jquery 以html格式检索表格式的xml数据

Jquery 以html格式检索表格式的xml数据,jquery,angularjs,ajax,xml,Jquery,Angularjs,Ajax,Xml,我想以表格格式检索HTML格式的XML数据。我尝试过使用ajax,但没有数据。这里可能有什么问题,有人能帮我吗。我是ajax新手。请随意说出我代码中的任何错误。下面是我想喜欢的图片 $(文档).ready(函数(){ $(窗口)。加载(函数(){ $.ajax({ 键入:“GET”, url:'2.xml', 数据类型:“xml”, 成功:函数myFunction(xml){ var i; var xmlDoc=xml.responseXML; var table=“ArtistTitle”

我想以表格格式检索HTML格式的XML数据。我尝试过使用ajax,但没有数据。这里可能有什么问题,有人能帮我吗。我是ajax新手。请随意说出我代码中的任何错误。下面是我想喜欢的图片

$(文档).ready(函数(){
$(窗口)。加载(函数(){
$.ajax({
键入:“GET”,
url:'2.xml',
数据类型:“xml”,
成功:函数myFunction(xml){
var i;
var xmlDoc=xml.responseXML;
var table=“ArtistTitle”;
var x=xmlDoc.getElementsByTagName(“行”);

对于(i=0;i您应该真正查看JQuery数据表,我一直使用它们用Ajax数据填充表


我认为您的代码的问题在于您在xmlDoc中没有定义

您可以通过以下代码实现它。

HTML


产品
过程
活动
描述
批处理
数量

JS

$.ajax({
键入:“GET”,
url:'data.xml',//您的xml数据
数据类型:“xml”,
成功:函数(xml){
$(xml).find(“行”).each(函数(){
var Product=$(this.find('Process').text()
var进程=$(this).find('Product').text()
var Operation=$(this).find('Operation').text()
var Description=$(this).find('Description').text()
var Batch=$(this).find('Batch').text()
变量数量=$(此).find('Qty').text()
$('demo tbody')。追加(''+产品+''+过程+''+操作+''+说明+''+批次+''+数量+'')
});
}
})

我收到了这个错误
e.indexOf
不是一个函数代码在我这边工作正常..你是否包括jquery并更改了url?检查错误链接
<table id="demo">
<thead>
    <th>Product</th>
    <th>Process</th>
    <th>Operation</th>
    <th>Description</th>
    <th>Batch</th>
    <th>Qty</th>
</thead>
<tbody></tbody>
$.ajax({
    type: 'GET',
    url: 'data.xml',//Your xml data
    dataType: 'xml',
    success: function(xml){
        $(xml).find("Row").each(function(){
            var Product = $( this ).find( 'Process' ).text()
            var Process = $( this ).find( 'Product' ).text()
            var Operation = $( this ).find( 'Operation' ).text()
            var Description = $( this ).find( 'Description' ).text()
            var Batch = $( this ).find( 'Batch' ).text()
            var Qty = $( this ).find( 'Qty' ).text()
            $('#demo tbody').append('<tr><td>'+Product+'</td><td>'+Process+'</td><td>'+Operation+'</td><td>'+Description+'</td><td>'+Batch+'</td><td>'+Qty+'</td></tr>')

        });
    }
    })