2011-10-30 116 views
0

如何從包含標題的iframe獲取內容content-type: text/plan如何獲取iframe內容?

是否可以在不重新加載內容的情況下使用$.ajax()加載內容?

iframe中的內容:

{"result":{"posts":0,"posts_imported":0},"error":{"file":{"msg":"ERR_ERROR_FILE","trans":{"file":"csv"}}}} 
+2

是在同一個域中包含'iframe'頁面的'iframe'的內容? – icktoofay

+0

你的意思是文本/平原的標題嗎? – halfer

+0

[.contents](http://api.jquery.com/contents/)? –

回答

-1

如何:

你的iframe的html文件:

一個div

<div id='iframeContent'> 
    {"result":{"posts":0,"posts_imported":0},"error":{"file":{"msg":"ERR_ERROR_FILE","trans":{"file":"csv"}}}} 
</div> 

那麼你的代碼來取代它會是這樣,我相信,

$('your-iframeid').childen('<div>',0).text(your-new-text); 

我是初學者;所以,我可能完全不在這一個(太)。

+0

確保縮進任何代碼,如HTML,JavaScript等4個空格在 - 或使用代碼工具欄按鈕(看起來像「{}」)。 – GregL

0

jQuery中:

var content = $("iframe").contents();