2017-10-28 16 views
-1

我有一个DIV中一个主要DIV我有6个不同的表,它表明API我从阿贾克斯节目表的结果,因为它的载入完成,从Ajax调用获取数据

调用的API的响应的事情是不每个API都会一直给出结果,所以我需要相应地显示

现在我正在使用.hide.show以获得特定的结果表。

问题是,如果我从第二个API获取数据,它将显示第二个位置的表格,之后,如果5,6获得响应,他们现在显示的是如果我获得3,4 API响应他们会在两者之间得到空间,我希望将3,4结果附加到列表中。

因此,对于用户(前端),它们显示为所有apis都在逐个响应并逐个显示数据。

<div class="insight text-center"> 
<table id="ssl_table" class="table table-hover" style="color: black; position: relative; z-index: 1000; background: white;"> 
</table> 
<table id="links_table" class="table table-hover" style="color: black; position: relative; z-index: 1000; background: white;"> 
</table> 
<table id="tag_table" class="table table-hover" style="color: black; position: relative; z-index: 1000; background: white;"> 
</table> 
<table id="drupal_table" class="table table-hover" style="color: black; position: relative; z-index: 1000; background: white;"> 
</table> 
<table id="wp_table" class="table table-hover" style="color: black; position: relative; z-index: 1000; background: white;"> 
</table> 
<table id="zx_table" class="table table-hover" style="color: black; position: relative; z-index: 1000; background: white;"> 
</table> 
<table id="ada_table" class="table table-hover" style="color: black; position: relative; z-index: 1000; background: white;"> 
</table> 
</div> 

我有6阿贾克斯这样

$.ajax({ 
    "async": true, 
    "crossDomain": true, 
    "url": "api_url", 
    "method": "POST", 
    "headers": { 
    "content-type": "application/x-www-form-urlencoded" 
    }, 
    "data": { 
    "url": "website_url 
    } 
} 
).done(function (response) { 
if (response.current) { 
    $('#wp_table').show(); 
} else { 
    $('#wp_table').hide(); 
    console.log('Error :',response) 
    } 
}).fail(function (jqXHR, response) { 
    $('#wp_table').hide(); 
    console.log('Failed',response); 

}); 
} 
+1

向我们展示您的脚本部分,您正在显示/隐藏表格 –

+0

添加了ajax,其中im显示了表格@SanchitPatiyal –

回答

-1

我的理解是什么,你让6个AJAX电话,你不知道哪一个是第一位的,哪一个在后面,真的吗?

OK,你并不需要所有的表,只想尽快将数据追加到DIV,因为它涉及:

的jQuery:

$("#insight-text-center").append(YOUR DATA); 

注意:你更好地追加到而不是class