-1

我用 jquery 加载了一个远程 html 文件并测试了它是否完美。我将该html内容存储在中$secPage,然后尝试在td中搜索文本$secPage,但为空。

$secPage = $(data);  
$('#content').html($secPage); // it works and shows data 
var result = $('td:contains("Ejendomsværdi:")',$secPage).next().text(); // returns empty

但是如果我用http://jsfiddle.net/测试相同的代码然后得到结果。

var result = $('td:contains("Ejendomsværdi:")').next().text();  // it works in jsfiddle

这意味着,当我使用$secPagethen 进行测试时,它返回空,但它不应该是。

请帮忙 ...

4

1 回答 1

1

As you say it's a remote file, I guess it means it comes from a different domain.

Then you can't do it : cross domain protection rules prevents you to read or change the content loaded from another domain (including port) unless the remote server allows it (using headers)

于 2012-09-19T06:32:48.060 回答