You don't say where the error is, but presumably it is in JS:
;
$_GET
data to make sure it conforms to the syntax of JS function names.Oh, I see you have tagged this as JSON-P, in that case:
Construct a single object with all the data, convert it to JSON with encode_json
, then wrap the whole thing with the callback( and );. Don't call the callback multiple times in a while loop.