Skip to content

Instantly share code, notes, and snippets.

@dallarosa
Created May 5, 2011 07:56
Show Gist options
  • Save dallarosa/956697 to your computer and use it in GitHub Desktop.
Save dallarosa/956697 to your computer and use it in GitHub Desktop.
checking the upload state with JS
<% form_for :lesson, @lesson, :url => {:action => "create"}, :html => { :multipart => true } do |form| %>
Nome: <%= form.text_field :name %><br/>
Descricao <%= form.text_field :description %><br/>
Video: <%= form.file_field :video %><br/>
<%= form.hidden_field :uuid, :value => @uuid%>
<%= form.submit %>
<% end %>
<div id="teste"></div>
<script type="text/javascript">
$("form").submit(
$("form").submit();
function() {
alert($("#teste").length);
$(document).everyTime(500,
function(){
$.getJSON("http://myserver.com/progress?X-Progress-ID="+$('#lesson_uuid').val(),
function(data){
//if(data.state == 'uploading')
$("#teste").text("state:" + data.state);
}
)
}
);
return false;
}
);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment