Got pagination and endless scroll working using javascript