Adding ajax pagination

This is done like that on purpose. If you put this check in `for` loop, you will check for this on each pass, this way we check this on start and depending on `if` result we show result.