Closed r4m closed 11 years ago
@r4m Sorry, I am not that familiar with Rails. This doesn't seem to be a front end issue but something your controller doesn't like about the request data perhaps. What are the reasons your controller would return a 406 Not Acceptable
?
@r4m could this be it? http://stackoverflow.com/questions/3751030/rails-3-returning-a-http-406-not-acceptable
I just solved it in this way:
1) remove jquery_ujs
from application.js
, in this way when an ajax call is started only 'eldarion-ajax' processes it
2) add javascript beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},
to eldarion-ajax-core.js
.
I'm gonna fork your project to add this and eventually push it to your repo if it could be useful for other guys
I'll move further to understand if it is possible to maintain compatibility between eldarion-ajax.js
and rails.js
just in case I need it.
Thanks for your instant-support @paltman ;)
@r4m I think that line with adding the CSRF token should remain outside of the eldarion-ajax library as I believe different frameworks and/or site developers will use CSRF tokens differently. For instance, I include this file in all my Django projects and it takes care of AJAX CSRF but is a bit different than your solution:
@paltman I agree infact I've seen the link you have referred through my chrome-web-dev noticing that you have managed by yourself the CSRF ;) from that I was able to run your lib on RoR. Thanks
Hi, I'm trying to use your js, which I find awesome, in a Rails app. Get requests are ok but I'm stucked into post/put requests. The problem is that for each post/put there are two requests that are routed to the backend, the first one is successfully completed, the second one fails:
At the first attempt everything is accomplished, giving back a json with the html content that the frontend is waiting for. The second one fails because the HTML response is not rendered by the backend (which is correct, since I've to send back a json to the eldarion-ajax success).
I do not know if this is happing due a conflict between
jquery_ujs
, which include all the functionalities ofrails.js
for the standard rails ajax requests, witheldarion-ajax
.Someone has an idea regarding that? Thanks!
Notice: if I disable
jquery_ujs
the backend response is the following: