Set variable in succes function to overwrite variable in ajax call
I have the following code:
var offset = 0;
jQuery(document).ready(
function() {
jQuery('ul.productlist').scrollExtend(
{
'target': 'ul.productlist',
'url': 'getmore.php?offset=' + offset,
onSuccess: function() {
offset = offset + 20;
},
'newElementClass': 'more'
}
);
}
);
I am trying to use the new offset the next time the url is called (it is being called every time the page scroll down to get more results i开发者_如何学编程n a dynamic list).
I want to set the offset, so the php page knows which results to serve next. I understand this is not possible, but I can't seem to find a solution.
Any ideas?
'url': function() {
return 'data.php?offset='+offset;
}
'onSuccess': function() {
offset = offset + 20;
},
passing the url as a function does the trick
精彩评论