var array = new Array();
$.get('comics.txt', function(data) {
array = data.split(",");
for(var i = 0; i < array.length; i++)
{
var $page = array[i];
$.ajax({
url: $page,
success: function(data) {
alert(data);
}
});
}
});
comics.txt是一个文件,其中包含了一些网址,用逗号分隔。
comics.txt is a file which contains some urls, separated by commas.
在上面的code时,$就不能正常工作; $页是正确的URL,但它不工作的情况下。警报(数据)导致拿出一个空白的警告框。我需要帮助找出一种方法来从被称为数组的数组中的每个页面获取数据。
In the above code, the $.ajax call does not work; $page is the correct url, but it's not working in the context. alert(data) causes a blank alert box to come up. I need help figuring out a way to get the data from each page in the array called array.
由于时间提前。
是 $页
在你的域上的URL?...如果不是,你不能做阿贾克斯。 ..
is $page
a url on your domain?... if not, you cannot do ajax...
如果是这样,我怎么能通过javascript从国外网址获取数据?
If so, how can I get data via javascript from foreign URLs?
您哟从你的服务器得到它...
you have yo get it from your server...
例如..
var array = new Array();
$.get('comics.txt', function(data) {
array = data.split(",");
for(var i = 0; i < array.length; i++)
{
var $page = array[i];
$.ajax({
url: 'your/server/url.php?page=' + $page,
success: function(data) {
alert(data);
}
});
}
});
你/服务器/ url.php
可以让页面为你...
your/server/url.php
can get the page for you...