开发者

How to parse string html from submitted iframe

开发者 https://www.devze.com 2023-01-27 01:30 出处:网络
I\'m uploading a file in an iframe (with name and id=upload_target) to some server. As a response it creates a callback json style :

I'm uploading a file in an iframe (with name and id=upload_target) to some server. As a response it creates a callback json style :

'result':'true'

So I'm trying the following. On onload action of my IFrame I've added an event listener, which should run function grabbing data :

function fileUploadFunction(){
    (...)
    $("#upload_target").onload = uploadDone;
 开发者_Go百科   (...)        
};

function uploadDone() {
    alert("uploadDone");
    var ret = frames['upload_target'].document.getElementsByTagName("body")[0].innerHTML;
    var data = eval("("+ret+")");

    if(data.result == 'true') {
        alert("GREAT SUCCESS !!");            
    }
    else {
        alert("GREAT FAILURE :(");
    }   
}

But as a result I'm not getting anything at all. Should I return callback status in different form, or can it be solved differently ? Because even the first alert from uploadDone is not shown problem probably lies somewhere else.


Probably the reason nothing is happening is because of the funky way you have to detect an iFrame is loaded. Check the post jQuery .ready in a dynamically inserted iframe. I am assuming you are using jQuery.

0

精彩评论

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