Javascript 从外部源加载特定数据
给定脚本在单击时从外部源的特定div加载数据。它从外部源的div加载所有数据。但现在我只想加载我想要的特定内容。就像只加载图像一样,然后按相同的顺序加载标题、贴子标签、日期和注释,而不是文本摘要 脚本:Javascript 从外部源加载特定数据,javascript,jquery,html,ajax,Javascript,Jquery,Html,Ajax,给定脚本在单击时从外部源的特定div加载数据。它从外部源的div加载所有数据。但现在我只想加载我想要的特定内容。就像只加载图像一样,然后按相同的顺序加载标题、贴子标签、日期和注释,而不是文本摘要 脚本: $(function() { var page = null; var counter = 0; function getNext() { // Grab the next element from the array of date-outer divs an
$(function() {
var page = null;
var counter = 0;
function getNext() {
// Grab the next element from the array of date-outer divs and copy it to the .content div
if (counter >= page.length)
return;
var elm = $(page[counter]).clone();
elm.find('script').remove(); // Remove script tags in the div
elm.appendTo('#load-here');
counter++;
}
$('button.btn').click(function(e) {
if (page === null) {
page = false; // Prevents the request from being made twice
$.get('http://test-html-site.blogspot.com/search/label/', function(data) {
page = $(data).find('.date-outer');
getNext();
});
} else if (page !== false) {
getNext();
}
});
});
<button class='btn'/>
<div id="load-here"></div> <!-- Load Here -->
</body>
HTML:
$(function() {
var page = null;
var counter = 0;
function getNext() {
// Grab the next element from the array of date-outer divs and copy it to the .content div
if (counter >= page.length)
return;
var elm = $(page[counter]).clone();
elm.find('script').remove(); // Remove script tags in the div
elm.appendTo('#load-here');
counter++;
}
$('button.btn').click(function(e) {
if (page === null) {
page = false; // Prevents the request from being made twice
$.get('http://test-html-site.blogspot.com/search/label/', function(data) {
page = $(data).find('.date-outer');
getNext();
});
} else if (page !== false) {
getNext();
}
});
});
<button class='btn'/>
<div id="load-here"></div> <!-- Load Here -->
</body>
外部站点示例
单身
我的问题是如何只加载特定的数据,如图像,然后按相同的顺序加载标题、贴子标签、日期和注释,而不是文本摘要。请尝试此代码段从外部源选择特定内容
$('#Destination-image1-Id').load('XXX.html #image1');
Ref:尝试使用此代码段从外部源选择特定内容
$('#Destination-image1-Id').load('XXX.html #image1');
Ref:不是这样的,请单击需要的功能,请参见此处:单击“单击此处”按钮时显示所有内容,但我想加载特定数据。不是这样的,请单击需要的功能,请参见此处:单击“单击此处”按钮时显示所有内容,但我想加载特定数据。