I'm trying to make ajax file upload . I read that it is not possible to do that without using iframe .
I wrote :

<iframe id="uploadTrg" name="uploadTrg" height="0" width="0" frameborder="0" scrolling="yes"></iframe>
<form id="myForm" action="file-component" method="post" enctype="multipart/form-data"  target="uploadTrg">
File: <input type="file" name="file">
<input type="submit" value="Submit" id="submitBtn"/>
</form>

and using jquery form plugin :

$('#myForm').ajaxForm({
    dataType:  'json',
    success:   function(data){
        alert(data.toSource());
    }
});

The Result :

the file is uploaded successfully and I can see the uploaded file , but a dialog box appears :

alt text

since I send back a json result to display the file name + size etc ..

My Question : How can I use the iFrame to be able to make " ajax file upload".

Note:

  1. I don't prefer to use special plugin to upload file , if there is more appropriate/easier solutions.
  2. I use jsp/servlets as a server-side language .. but I think it does not make sense which language I use .

Thanks

Edit
Report