views:

54

answers:

2

When i create a form like this:

<form method='POST' action='gate.py'>
    <input type='file' />
</form>

1) How i cant catch the response from the server, on a script?

2) I can send in a async way a file?

Thanks in advance.

+1  A: 

Take a look:

Ajax File Upload: http://www.webtoolkit.info/ajax-file-upload.html

JQuery Form Plugin: http://jquery.malsup.com/form/#getting-started

Minh Nguyen
+3  A: 

One option is to post your form to a hidden iframe:

<iframe id="hidden-frame" name="hidden-frame" src="" style="width:0; height:0; display: none;;"></iframe>
<form method="POST" action="gate.py" target="hidden-frame">
    <input type="file" />
</form>

Then from your "gate.py" script return some JavaScript code according to the result of the upload:

<script type="text/javascript>
    alert('Upload Successful');
</script>

You could also interact with the parent to update a <div> with the response.

On the other hand, you could also consider using a third-party plugin like Uploadify.

Daniel Vassallo
Thanks your answer, but it's painful to me because i want to pass a xml document and the file but the xml document it's auto-generated by the page.
hidura