Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript response not executing #81

Closed
san opened this issue Jun 6, 2013 · 5 comments
Closed

Javascript response not executing #81

san opened this issue Jun 6, 2013 · 5 comments

Comments

@san
Copy link

san commented Jun 6, 2013

I have a rails 3.2.12 application. Just updated to the latest remotipart, latest rails-ujs and latest jquery and now my .js.erb is not executing when uploading a file via an Ajax form.
I am using chrome developer tools to debug. I see the form being submitted as a POST request, which is what remotipart does. The response coming back (with Content-Type: text/html) is:

<!DOCTYPE html>
<html>
  <body>
    <textarea data-status='200' data-statusText='OK' data-type='text/html'>
      <textarea data-type="text/javascript" response-code="200">
        $('#some-modal').modal('hide');
      </textarea>
    </textarea>
  </body>
</html>

If I copy the javascript code and run it in the console, it executes just fine.

Any idea whats going on. I looked into render_overrides.rb and see that its generating the inner textarea tag. Where is the outer text area coming from?

Thanks.

@JangoSteve
Copy link
Owner

It looks like you have some other rack middleware that's creating that outer textarea. It actually looks like what remotipart now produces as of yesterday, but when you submitted this a month ago, remotipart was not generating anything like that outer textarea. I think this is an issue with another library that's injecting it's own middleware, or something else in your rails app.

@drakmail
Copy link

drakmail commented Jul 6, 2013

Has same problems with 1.1.1

My Middlewares:

use ActionDispatch::Static
use Rack::Lock
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007ff009e8f750>
use Rack::Runtime
use Rack::MethodOverride
use ActionDispatch::RequestId
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use ActionDispatch::DebugExceptions
use BetterErrors::Middleware
use ActionDispatch::RemoteIp
use ActionDispatch::Reloader
use ActionDispatch::Callbacks
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use ActiveRecord::QueryCache
use ActionDispatch::Cookies
use ActiveRecord::SessionStore
use ActionDispatch::Flash
use ActionDispatch::ParamsParser
use Remotipart::Middleware
use ActionDispatch::Head
use Rack::ConditionalGet
use Rack::ETag
use ActionDispatch::BestStandardsSupport
use Warden::Manager
use JQuery::FileUpload::Rails::Middleware
use OmniAuth::Strategies::Facebook
use OmniAuth::Strategies::Vkontakte
run SomeApp::Application.routes

@drakmail
Copy link

drakmail commented Jul 6, 2013

After removing jquery-file-upload middleware problem still exists:

use ActionDispatch::Static
use Rack::Lock
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007fbaf7989a40>
use Rack::Runtime
use Rack::MethodOverride
use ActionDispatch::RequestId
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use ActionDispatch::DebugExceptions
use BetterErrors::Middleware
use ActionDispatch::RemoteIp
use ActionDispatch::Reloader
use ActionDispatch::Callbacks
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use ActiveRecord::QueryCache
use ActionDispatch::Cookies
use ActiveRecord::SessionStore
use ActionDispatch::Flash
use ActionDispatch::ParamsParser
use Remotipart::Middleware
use ActionDispatch::Head
use Rack::ConditionalGet
use Rack::ETag
use ActionDispatch::BestStandardsSupport
use Warden::Manager
use OmniAuth::Strategies::Facebook
use OmniAuth::Strategies::Vkontakte
run SomeApp::Application.routes

@drakmail
Copy link

drakmail commented Jul 6, 2013

Seems, that I have other problem...

@JangoSteve
Copy link
Owner

Considering that the remotipart response is the inside of those two textareas, I would guess the offending middleware would have to be listed after remotipart in that list (assuming the middlwares run in the same order they're listed in the rake task, which I believe they do). That would narrow it down to:

use ActionDispatch::Head
use Rack::ConditionalGet
use Rack::ETag
use ActionDispatch::BestStandardsSupport
use Warden::Manager
use JQuery::FileUpload::Rails::Middleware
use OmniAuth::Strategies::Facebook
use OmniAuth::Strategies::Vkontakte
run SomeApp::Application.routes

Also, given that it looks like it's some middleware doing the same textarea workaround for an iframe upload, my guess is it's JQuery::FileUpload. I looked up their middleware, and sure enough it matches exactly what you're seeing, so I'd say that's definitely the issue.

Keep in mind that after you remove the jquery-fileupload-rails gem, you have to re-run bundle install and then restart your rails server for it to take effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants