2017-03-02 25 views
1

任何人都可以幫助我使用JQuery將響應加載到iframe中。 我嘗試了以下方法。使用jquery將響應加載到iframe中

$.post(url, $("formid").serialize(), function(data) { 
$("#myIframe").contents().html(data); 
}) 

我不想做

$(".myIframe").attr('src', "myServlet/"+encodedParam); 

因爲這也將暴露在data.And即無法加載比2038個字符有URL窗口。 在此先感謝。

+0

看看http://stackoverflow.com/questions/4689145/pass-jquery - 變量的iframe間 - 和 - 親 –

回答

0

嘗試使用$("#myIframe").contents().find('html').html(data);

0
var iframe = $("#Iframe")[0].contentWindow.document; 
       iframe.open(); 
       iframe.write(data); 
       iframe.close(); 

該解決方案爲我 非常感謝響應:)