开发者

Retrieving iframe contents after a form submitted to it

开发者 https://www.devze.com 2023-04-09 16:06 出处:网络
I have a form with an iframe as its target, and I want to retrieve 开发者_运维技巧its contents after the form has been submitted.

I have a form with an iframe as its target, and I want to retrieve 开发者_运维技巧its contents after the form has been submitted.

The problem is if I do something like:

$('form').submit(function (e) {
    e.preventDefault();
    var content = $('iframe').contents();
});

I get nothing because the form only submits after this. Is there any event that I can use AFTER the iframe received its content?

Thanks.


Try using the load event of the iframe.

$("iframe").load(function(){
  var response = this.document.getElementsByTagName("body").innerHTML;
  alert(response);
});
0

精彩评论

暂无评论...
验证码 换一张
取 消