Ninad Pundalik a écrit :
Hi All,
The start of the GSoC coding period is just around the corner, and I would like to start writing some useful code as soon as possible. I have a few questions before I start doing that though. In my proposal, I have mentioned one of my tasks as writing functions that will wrap the output of AJAX requests in well-formed XML. Over the last few days, I have been trying to figure out how to do this. Should I use output buffering at the start of an ajax request, read the entire output buffer into a string variable and then construct either a DOM or a SimpleXML object from that string when the request ends? Or, is there a better way of doing this?
Hi Ninad,
In your deliverables you wrote: "2. Functions that will wrap the output in well formed XML, so that jQuery can correctly parse the response and insert the right content at the right location in the page."
I guess that this would not be necessary if you use JSON?
Also, when I checked out the latest version from git, I could see that a jQuery JSON plugin has been added in the js/jquery folder. If this plugin is being used, should the output for AJAX requests be in JSON instead of XML? I feel it would be a lot more easier to handle the output in JSON rather than XML.
Indeed.
For the AJAX calls, do I use the jQuery's $.get/$.post/$.ajax methods directly or should I build wrapper functions around them?
Please do not use wrappers that do nothing; as a bad example in PHP:
// I find cool to use my_echo('Hello'); function my_echo($message) { echo $message; }
Last, where should I put all the jQuery scripts that will be written over the next few weeks in the tree? Should I keep it in a js/ajax folder for the period of this summer, and then merge it later into the js folder after the features have been sufficiently tested?
I suggest to put them under /js.