... in the context of one element I need to check?
I never faced the problem of uploading using iframe without jQuery, but now I think about uploading from ajax callback which contains a form, an iframe:
<form enctype="multipart/form-data" action="get.imageupload.php" id="upload_form" method="post">
<input name="userfile" type="file" id="file" />
<input type="submit" name="action" value="start" />
<input type="hidden" name="id" value="<?=$id;?>" />
<iframe id="upload_target" name="upload_target" src="" style="width:0;height:0;border:0"></iframe>
</form>
and the following js:
$("#upload_form").submit(function() {
$(this).attr("target","upload_target");
$("iframe", this).load(function() {
var ret = $("iframe", "#upload_form").contents().find("body").html();
var data = eval("("+ret+")");
if (data.success) alert("success"); // todo
if (data.failure) alert("fail"); // todo
});
return false;
});
I have to handle a request from get.imageupload.php
that returns JSON data, therefore js looks like that.
The problem is: load(fn)
doesn't work; ready(fn)
instead does, but iframe
is empty, because an event fires before the uploading starts... I'm newbie in jQuery and maybe there is another way?
Any ideas?
Thanx