jscroll icon indicating copy to clipboard operation
jscroll copied to clipboard

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

Open merutak opened this issue 10 years ago • 4 comments
trafficstars

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.

merutak avatar Jul 18 '15 20:07 merutak

+1 for this feature.

danielson317 avatar Aug 26 '15 20:08 danielson317

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 avatar Mar 10 '16 10:03 jevanlingen

@pklauzinski; Any change this PR will be merged?

jevanlingen avatar Oct 06 '16 10:10 jevanlingen

+1 for this feature

gcrispyn avatar Jul 03 '17 15:07 gcrispyn