Ruby on Rails Sunday, March 6, 2016

On 6 March 2016 at 18:22, Donald Ziesig <donald@ziesig.org> wrote:
> Hi Everyone,
>
> I am having a problem getting Rails to render a page when it is called from
> javascript/ajax. I posted a detailed question on StackOverflow but no one
> has answered yet. (Rails 5 will not render POST made from javascript)
>
> Basically, I am doing a very simple ajax POST (also tried GET with same
> results), the equivalent of: localhost:3000/lockout/2016-03-16.
>
> The ajax request gets past routes.rb, and calls the appropriate method in
> the controller. The controller processes it correctly (database is updated,
> debug print statements show up in log, etc.) but it does NOT render.
>
> When I submit the same request manually from the browser (as a GET) it again
> is processed correctly, but then it DOES render.
>
> In all cases the log shows this (with times slightly different):
>
> Started POST "/lockout/2016-03-16" for 127.0.0.1 at 2016-03-06 13:05:22
> -0500
> Processing by LockoutsController#toggle as HTML
> *
> *
> *
> Rendered lockouts/toggle.html.erb within layouts/application (0.6ms)
> Completed 200 OK in 244ms (Views: 203.0ms | ActiveRecord: 11.4ms)
>
> In fact, the log shows identical entries from the original Started GET/POST
> line for all attempts at invoking the method, but only when the URL is
> entered manually will the view render.
>
> BTW, the ajax is called from fullcalendar's dayClick event if that helps.
> fullcalendar's eventClick events DO render.
>
> Does anyone have any ideas?

Can you show us the code you are you using to do the post?

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsGhCkS62BXdo58xMsmyhkY%2B02gOapatqFqetywWxjcbg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment