Zach S Zach S - 1 year ago 131
Ajax Question

Rails Ajax Error: Turbolinks undefined

I'm using Rails 4.2 and I want to send an ajax request to my server. But the request always fails with the error

Turbolinks is not defined
. My rails console returns a 200 ok response.
I am using the 'jquery-turbolinks' gem.

Thanks in advance!


type: "PUT",
url: "http://localhost:3000",
data: xx,
success: function(data){
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("some error");


def upvote
# code here
respond_to do |format|
format.html { redirect_to :back }
format.json { head :ok }
format.js { head :ok }

Answer Source

In application.js, are you requiring jquery.turbolinks between jquery and turbolinks like below?

//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require masonry/jquery.masonry
//= require turbolinks
//= require_tree .

If your turbolinks version is 5, jquery-turbolinks gem doesn't support turbolinks 5. So, at the moment, you have to add JS for compatibility reffering this issue (see Lowryderch's comment). Put the under app/assets/javascripts/ folder.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download