2014-01-29 52 views
0

我需要返回http://service.semanticproxy.com/processurl/ftfu27m3k66dvc3r43bzfneh/html/http://www.smallbiztechnology.com/archive/2013/12/why-creating-a-digital-storefront-is-crucial-for-your-small-business.html本页内容的完整的HTML页面,但是当我调用该函数我需要返回使用Ajax调用

function getResult() { 
      var url="http://service.semanticproxy.com/processurl/ftfu27m3k66dvc3r43bzfneh/html/http://www.smallbiztechnology.com/archive/2013/12/why-creating-a-digital-storefront-is-crucial-for-your-small-business.html"; 
      $.ajax({ 
       cache: true, 
       url: url, 
       success: function (result) { 
        alert(result); 
       } 
      }); 
     } 

我的萤火得到这个:

段。 min.js(ligne 1) GET http://service.semanticproxy.com/processurl/ftfu...orefront-is-crucial-for-your-small-business.html 200 OK 379msA。

任何想法如何我可以得到该网页的内容?

+2

您正在运行相同的原产地策略。研究跨域AJAX。 –

+0

该URL不允许来自不同域的请求,您需要在服务器上托管自己的代理脚本,以便下载并返回URL的内容。 –

回答

0

此代码不适用于您。原因是您尝试检索的html页面不是有效的JAVASCRIPT文件(并且您也无法使用jsonp,因为它不返回任何json字符串。)

您的解决方案是使用服务器脚本(如php:

<?Php print file_get_contents(url); ?> 

)。

或者 - 如果网站是您的,请根据要求在脚本中添加回复。