I need to display an image in an iframe from a dynamically generated string. The iframe's id is upload_target.
This is the code I'm using
// assign esrc and upath
$.ajax
({ type: "POST",
url: "editImage.php",
data: {esrc: editsource, upath: upath } ,
success: function(esource)
{ //load into iframe
s = esource;
console.log(s);
$('#upload_target').contents().find('body').html(s);
}
});
The file editImage.php simply returns the right file name. The console shows up the right filename, so I know there's no problem there. But nothing happens to the iframe, it just stays as blank as ever. I was able to populate the same iframe with another event, namely the submission of a form whose target was this iframe. But why isn't it working here?
I also tried $('#upload_target').attr('src',s), but I got a 406 error.