On 6/12/07, Chris W. Parker <[EMAIL PROTECTED]> wrote:
Hello, What's the standard method for fitting an existing site with AJAX functionality? Currently all my server side files that process requests, like deleting rows from a database (e.g. customers, products, etc.), automatically redirect the user to another page with a status message (e.g. success/failure). But now that I'm trying to add some AJAX functionality to this existing site I'm not sure how to handle the server side of it. 1. Is it a better practice to create totally new AJAX specific server files? 2. Or is it a better practice to modify the existing files to know that an AJAX request is being made and that they should (1) not redirect and (2) return the data in a different format? I'm opting for #1 but I can see this might also be an issue because of the need to maintain multiple files. Chris Parker Aardvark Tactical, Inc. IT Manager 1002 W Tenth St. Azusa, CA 91702 phone: 800.997.3773 x131 fax: 626.334.6860 [EMAIL PROTECTED]
I believe it is technically feasible to use either method, although one may end up being more convoluted than the other depending on your circumstances. I think it all comes down to preference and personal style (if its a solo project), or the current conventions of whatever team you may be on. What it really depends on though, IMHO, is your current coding style. Personally, I prefer OO and MVC, where I have a response object that has a boolean isAjax variable that I can check (which can be set with HTTP_X_REQUESTED_WITH, HTTP_CONTENT_TYPE, or a GET variable). The only fundamental difference in the 2 responses will be the view file, which contains the HTML of the response. If its AJAX, it only need contain information to update the DOM; otherwise, if not AJAX, it can still do anything, including redirect logic (like a redirect header).
<<inline: sig_logo_rsml.gif>>