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

Multiple AJAX requests (one successful and the rest cancelled) with a remote form #5

Closed
NicolayD opened this issue Dec 7, 2017 · 2 comments

Comments

@NicolayD
Copy link

NicolayD commented Dec 7, 2017

Following the instructions in the README, I made a search form that sends an AJAX request and everything was working fine at first, together with the turbolinks. However, I noticed that every time I submitted the form, there was one additional and identical cancelled AJAX request. The requests were piling up so this started slowing the page down eventually.

The solution that I found was moving the <script src="<%= static_path(@conn, "/js/app.js") %>"></script> in app.html.eex from the body to the head.

Maybe there's a better solution. I'm not sure if Turbolinks.clearCache() could work - tried using it to no avail (maybe I tried the wrong approach though). In any case, I think this issue should be discussed.

@NicolayD NicolayD changed the title Multiple AJAX requests whit a remote form Multiple AJAX requests (one successful and the rest cancelled) with a remote form Dec 7, 2017
@dokuzbir
Copy link

dokuzbir commented Jan 8, 2018

for disable cache you can use that tag
meta name="turbolinks-cache-control" content="no-cache"

@imranismail
Copy link
Owner

imranismail commented Jan 11, 2018

I've updated the README, I hope this clarifies it:

head
++  meta name="csrf-token" content="#{get_csrf_token()}"
++  meta name="csrf-param" content="_csrf_token"
  ...
--  script src="#{static_path(@conn, "/js/app.js")}"
++  script data-turbolinks-track="reload" src="#{static_path(@conn, "/js/app.js")}"
  ...
body
  ...

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