My server side php outputs json
{“total_count”:xxx, “pos”:0, “data”:[…]}
on first request and first items are rendered correctly. But when more data is requested and php outputs
{“pos”:$posStart, “data”:[…]}
on next requests, items are not showing up in dataview and it keeps requesting them. I checked and data is returned correctly with requested counted items and ‘pos’ set to requested posStart position.
What am I doing wrong?
<?php
$posStart = 0;
if(isset($_GET["posStart"]))
$posStart = intval($_GET["posStart"]);
$count=25;
if(isset($_GET["count"]))
$count = intval($_GET["count"]);
$found = [];
.... $found is populated here and contains $count number of entries, $total is determined
echo json_encode($posStart == 0?["total_count"=>$total,"pos"=>$posStart, "data"=>$found]:["pos"=>$posStart, "data"=>$found]);
?>
By debugging Itracked it down to the wrong DataDriver being used to parse json results. It’s using xml driver instead and fails.
Is there a bug or I’m incorrectly setting up DataView?
I’m calling load like this:
dropsData.load("drops_data.php", "json");
php scrips also sets correct content-type headers.
As I said first results are parsed correctly as json, but for next is seems xml parser is wrongly used.
How do I avoid that?
I tried to call
dropsData.data.setDriver("json");
But it didn’t help.
Also, if I set a callback function to ‘load’ like this: