獲取

2010-06-24 35 views
2

我使用的東西像 document.body.innerHTML外部網頁的HTML源代碼,但我不需要我的網頁源代碼,我需要它來獲取外部頁面的源代碼,因爲獲取

new Ajax.Updater ({success:'employerBox'}, '<%=appRootPath%>/userBoxHome.asp?isEmployer=true&ajaxLogin=home', {evalScripts: true});

是不是工作在IE我需要div employerBox以獲取更新的內容/userBoxHome.asp?isEmployer=true&ajaxLogin=home

任何建議,請或我失蹤的任何功能?

我的想法,我知道代碼是錯誤的,是做這樣的事情document.body.innerHTML('userBoxHome.asp?isEmployer=true&ajaxLogin=home')

+0

一切都是在同一個域。 - 以防萬一 – BoDiE2003 2010-06-24 20:14:44

+0

[如何將html頁面包含到html頁面中]的可能重複(http://stackoverflow.com/questions/676394/how-to-include-an-html-page-into-an- html-page) – 2013-08-13 02:09:45

回答

2
function updateEmployerBox(){ 
    var div=$('employerBox'); 
    var url='<%=appRootPath%>/userBoxHome.asp?isEmployer=true&ajaxLogin=home'; 
    var options = { 
     method:'get', 
     onSuccess: function(transport){ 
      div.innerHTML=transport.responseText; 
     }, 
     onFailure: function(transport){ 
      alert('Failed '+transport.responseText); 
     } 
    };//end options 
    new Ajax.Request(url,options); 
} 
+0

「Ajax.Request」是這個原型嗎?只是好奇,谷歌的一個快速看起來似乎是這樣認爲的。 – sworoc 2010-06-25 18:40:06

+0

它是原型。問題被標記爲這樣,這個標記是不正確的? – stormdrain 2010-06-25 19:01:20