@@ -65,7 +65,11 @@ proto.loadNextPage = function() {
6565 this . onPageError ( error , path ) ;
6666 } . bind ( this ) ;
6767
68- request ( path , this . options . responseType , onLoad , onError ) ;
68+ var onLast = function ( response ) {
69+ this . lastPageReached ( response , path ) ;
70+ } . bind ( this ) ;
71+
72+ request ( path , this . options . responseType , onLoad , onError , onLast ) ;
6973 this . dispatchEvent ( 'request' , null , [ path ] ) ;
7074} ;
7175
@@ -263,7 +267,7 @@ proto.stopPrefill = function() {
263267
264268// -------------------------- request -------------------------- //
265269
266- function request ( url , responseType , onLoad , onError ) {
270+ function request ( url , responseType , onLoad , onError , onLast ) {
267271 var req = new XMLHttpRequest ( ) ;
268272 req . open ( 'GET' , url , true ) ;
269273 // set responseType document to return DOM
@@ -275,6 +279,8 @@ function request( url, responseType, onLoad, onError ) {
275279 req . onload = function ( ) {
276280 if ( req . status == 200 ) {
277281 onLoad ( req . response ) ;
282+ } else if ( req . status == 204 ) {
283+ onLast ( req . response ) ;
278284 } else {
279285 // not 200 OK, error
280286 var error = new Error ( req . statusText ) ;
0 commit comments