I am trying to show progress upload information on the same page as I start upload (for example index.php). So I simply start upload, it uploads, I open new tab http://domain.com/progress?X-Progress-ID=test and see the JSON output: { "state" : "uploading", "received" : 4422060, "size" : 5358641366 }
But Jquery script does not want to work.. However if I let file being uploaded and open this page in next tab, javascript shows me needed information. How to fit this into one file to make it work? So I start uploading a file and then it starts to show me response from calling GET another url.
Thanks in advance.
Form
<form id="upload" action="/upload/?X-Progress-ID=test" enctype="multipart/form-data" method="post">
<label for="jfile">File Upload:
<input id="jfile" name="file" type="file" />
</label>
<input type="submit" value="Upload File" />
</form>
Jquery
<script>
$(function() {
setInterval(function() {
$.ajax({
type: 'GET',
url: '/progress?X-Progress-ID=test',
dataType: 'json',
cache: false,
success: function (data) {
alert(data.state);
});
}, 500);
});
</script>