I have a JavaScript function that sends data to my PHP script via $.ajax. My PHP script returns a number of things that I use to create a Jquery UI dialog box, such as the title of the box and its contents (html).
I am returning the bits of data (such as the dialog title and body) in one long string, with each segment separated by ::, then using:
myStuff = data.split('::') ;
Finally, I use myStuff[n] for the first part I want to use.
I would like to know if you guys know a better way of doing this? Better as in faster/less code, more secure etc.
I believe that using a JSON object would be more appropriate. It would make the code more readable and would avoid the parsing, as Javascript can natively parse JSON objects:
There are many choices for creating JSON objects in PHP to chose from.