Note that there are some explanatory texts on larger screens.

plurals
  1. POMonitoring a server-side process on Rails application using AJAX XMLHttpRequest
    primarykey
    data
    text
    <p>I'm using the following in the web page but can't get a response from the server while it's processing</p> <pre><code>&lt;script type="text/javascript"&gt; &lt;!-- function updateProgress() { //alert('Hello'); new Ajax.Request('/fmfiles/progress_monitor', { parameters: 'authenticity_token=' + encodeURIComponent(AUTH_TOKEN), onSuccess: function(response) { alert(response.responseText); fillProgress('progressBar',response.responseText); } }); } //--&gt; &lt;/script&gt; &lt;% form_for( :fmfile, :url =&gt; '/fmfiles', :html =&gt; { :method =&gt; :post, :name =&gt; 'Form_Import', :enctype =&gt; 'multipart/form-data' } ) do |f| %&gt; ... &lt;%= f.file_field :document, :accept =&gt; 'text/xml', :name =&gt; 'fmfile_document' %&gt; &lt;%= submit_tag 'Import', :onClick =&gt; "setInterval('updateProgress()', 2000);" %&gt; </code></pre> <p>The 'create' method in fmfiles_controller.rb then happily processes the file and gets the right results (as per the submit button on the form). If I uncomment the '//alert('Hello')' line I get a dialog saying Hello every 2 seconds ... as expected.</p> <p>However, the server never logs any call to 'progress_monitor' method in 'files' not even a failed attempt.</p> <p>If I click the link</p> <pre><code>&lt;a href="#" onclick="updateProgress();"&gt;Run&lt;/a&gt; </code></pre> <p>it makes a call to the server, gets a response and displays the dialog, so I assume the routes and syntax and naming is all OK.</p> <p>I really don't know why this isn't working. Is it because 2 methods in the same controller are being called via URLs?</p> <p>I'm using Rails 2.1.0 in a development environment on OS X 10.5.5 and using Safari 3.1.2</p> <p>(N.B. This follows on from another <a href="https://stackoverflow.com/questions/120201/updating-server-side-progress-on-rails-application">question</a>, but I think it's sufficiently different to merit its own question.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload