Monday, July 03, 2006

some more Ajax where it really makes sense

I've put some more Ajax into BAOssimo!
looking around at the different frameworks it was quickly evident that the minimal solution would be the best: my-bic just does the dirty work around the asynchronous communication - all the set-up is completely configurable by the developer
This means more manual work but also more flexibility.
Another big plus for me is that it is readily wrapped in PHP.
I want to share some points that made initial deployment difficult for me:

1. in one of the tutorials given by my-bic an element id of 'content' is used - this seems to be a keyword for the global document --> changing the innerHTML of 'content' replaced the entire document for me
Solution: use a different id like 'changingContent'.

2. depending on the browser special characters got mixed up. BAOssimo is a site in French language and therefore uses lots of special characters everywhere (using iso-8859-1) .
Solution: edit mybic_server.php and add the following line
header("Content-type: text/html; charset=iso-8859-1");
before
echo $response;
similarly if you need to convert postings back to iso-8859-1 on the server side (they arrive there as utf-8) as follows before plugging them into your mysql database:
$posted_text = mb_convert_encoding(urldecode($this->queryVars['posting_textfield']), "ISO-8859-1", "UTF-8");


In general: be careful not to open up any new holes in your secure CMS ;) - SQL injection etc...

For an example have a look at the filter implementation on BAOssimo! Resto (site in French, as I said, but you'll see how it works easily enough).

Several other blogs have discussed my-bic before me:
http://www.mipsscan.com/2006/03/easy_ajax.html
http://ajaxian.com/archives/my-bic-ajax-state-of-mind-for-php-harmony
http://blogs.vinuthomas.com/2006/03/08/my-bic-easy-ajax/
http://marksdigital.com/blog/2006/03/04/my-bic-easy-ajax/
http://www.burnmytime.com/blog/2006/04/27/my-bic-vertrigoserv-killer/

0 Comments:

Post a Comment

<< Home