We have a problem to solve here. All our back end gets routed through index.php,
hence the header and other files get included automatically on all calls. We do not
need them on our AJAX calls. To avoid this, we will use PHP's output buffering
system. In index.php, we will start buffering the output via ob_start(). At the end
of index.php??”once all operations are done??”we will flush the output buffer with
ob_end_flush(). This will ensure other pages work well. Now at the beginning of
our AJAX handler, we will simply do an ob_end_clean() to discard current output
buffers and stop further buffering. We can then output whatever we want. At the
end of our handler, we will exit(), so that no footer code will be shown as well.
Mobile AJAX
[ 184 ]
In terms of page structure, we will have a few
tags. The main div will be the
one that will hold the recipe and comments. We will have a div for the comment form
also??”but it will be hidden at the start. We will have a