Seems like this part causes the issue in my PHP. I run it to update the filtred total records before echoing the results.
$sql = "SELECT count(*) FROM test" . $filterQuery;
$stmt = $conn->prepare($sql);
$stmt->execute($filterParam);
$total_Records = $stmt->fetchColumn();
1. Filtering - 1 Match, Response: {"totalRecords":1,"curPage":1,"data":[{... --CORRECT
2. Filtering - 0 Match, Response: {"totalRecords":0,"curPage":1,"data":[]} --CORRECT
3. Filtering (back to same filter value as 1) - 0 Match, Response: {"totalRecords":1,"curPage":0,"data":[]} --INCORRECT
No 3, should give same response as 1, also why do curPage get requested with value 0?
If I remove above code, everything works fine. Any idea? Sorry no jsfiddle available atm.