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

enable using $.ajax instead of load() using a callback #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

merutak
Copy link

@merutak merutak commented Jul 18, 2015

Let client use AJAX (e.g. POST) instead of just HTML loading. This can be useful:

  1. Let the server know how the previous page worked out (e.g. how much conversion, how long the user spent on it, etc.)
  2. Items are returned in non-HTML (e.g. JSON; especially the link to the next page) and need deserialization before jscroll gets to process them.

This is done by hooking options.loadFunc and providing an arbitrary asynchronous loading function there.

Of course load() is still the default.

@danielson317
Copy link

+1 for this feature.

@jevanlingen
Copy link
Contributor

The way you wrote it won't work, as the this scope is gone in your callback function. So change

target.load(data.nextHref, function (r, status) { callback(status); });

to

target.load(data.nextHref, function (r, status) { $.proxy(callback, target)(status); });

N.B.
I don't have push access to your branch, so I am writing this as a comment instead of fixing your PR.

@jevanlingen
Copy link
Contributor

@pklauzinski; Any change this PR will be merged?

@pklauzinski pklauzinski self-assigned this Oct 6, 2016
@gcrispyn
Copy link

gcrispyn commented Jul 3, 2017

+1 for this feature

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

Successfully merging this pull request may close these issues.

None yet

5 participants