-2

Context:

I want to get multiple values from my database with ajax and php. I see previous post about this (like How to get multiple responses from PHP file via AJAX? ) but all the time it seems the number of values is already known.

I have to return unknown number of values because i dont know how many roxs will be selected.

Question:

Are they tricks to get unknown number of values with ajax or should i put data in different arrays and then return them?

Thanks for your answer.

Community
  • 1
  • 1
Ryokel
  • 80
  • 8
  • 1
    -1 show your code, your effort – toesslab May 15 '14 at 08:29
  • I dont know why you are under voting guys, i ask to people with more experience how they handle this problem. I dont want the anwser for doing this i want the best way to handle it. So no code will following. thanks. – Ryokel May 15 '14 at 08:46

1 Answers1

-1

You should use JSON.

//PHP side
echo json_encode([$var1, $var2, $var3]);

//JS side
var array = JSON.parse(xhr.responseText);
Lord Grosse Jeanine
  • 1,111
  • 10
  • 29