0
votes

I'm using jQuery Infinite scroll plugin for pagination. The pagination URL is dynamic as it is returned from API. This code works till sending the Ajax request.

$('#stream').infinitescroll({
    navSelector     : ".paginate:last",
    nextSelector    : "a.paginate:last",
    dataType    : 'json',
    appendCallback  : false,
    path: function(path,page){
     return $("a.paginate:last").attr("href");
    }
}, function(json, opts){

});

But I have to set request header in the Ajax call for authentication in the server side.

How to pass request headers with the url.

Thanks,
Srikanth

1

1 Answers

0
votes

Right now there is no solution via Infinite Scroll ,

One solution that worked is, Adding the headers to global ajax handler.

$.ajaxSetup({
  beforeSend: setHeader
});

var setHeader = function (xhr) {
  xhr.setRequestHeader('Header1', 'XXX');
  xhr.setRequestHeader('Header2', 'YYY');
}

Cheers!