2014-01-29 86 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); ?> 

)。

或者 - 如果網站是您的,請根據要求在腳本中添加回復。