This question already has an answer here:
I need to pass a php variable to a jquery function. the php variable is an array of unknown size. is there a way to pass each member of the array to be processed individually by the function?
This question already has an answer here: I need to pass a php variable to a jquery function. the php variable is an array of unknown size. is there a way to pass each member of the array to be processed individually by the function? |
|||
marked as duplicate by deceze, MaVRoSCy, Mohammad Adil, HAL9000, Felix Kling Jun 11 '13 at 8:04This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. |
|||
|
You can use JSON to print the array and parse that to receive a JS object. I assume you use AJAX (directly printing into the javascript source is possible but ill-advised). Your php script needs to print output directly:
And on the receiving end use $.parseJSON:
|
|||||||||
|
I Guess you should use JSON to pass the php variable to jquery. its the easiest way to do that. |
|||
|