0

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;
    (...)        
};

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.

mastodon
  • 497
  • 5
  • 11
  • 22

1 Answers1

0

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.

Community
  • 1
  • 1
Erik Philips
  • 53,428
  • 11
  • 128
  • 150