PHP side (Server side)
On the server side, here is the code for the start_proc.php which starts a background process Read more
Ajax/Prototype/JSON PeriodicalUpdater: A working example – log update on a background process (Part 1/2)
This blog shows a real working Ajax.PeriodicalUpdater example (not just a hello world or non stop show timer). The example uses the PeriodicalUpdater to display a constantly updated log file from a background process running on the webserver. When the process finishes, the PeriodicalUpdater stops itself. Also a simple short PHP script is shown how to launch and check the status of a background process. Read more
The CSS SyntaxHighlighter 2.0 can be used with <pre> or <textarea> tags. However if you have to use with <textarea>, you may have some little surprise that it won’t be <textarea> anymore once the content is highlighted. Because the highlighter will replace the DOM node (same applied to <pre> tag) – according to the source code SyntaxHighligher.sh.highlight( ) in shCore.js. You will get a new <div> node instead – that’s the only way to have colorful syntax highlight on your page. Read more
I have been trying to create file upload form in Ajax. Most of the tutorials I found are using <IFRAME> technique as a hidden frame. In OpenJS, it gives an excellent tutorial. In a nutshell, the file upload form redirects the reload action into the hidden frame. Then uses the top window to fetch the results (using JSON) when the hidden frame is loaded which indicates a file has been uploaded. This technique involves setting up the onload and onsubmit event handlers while the main page is loaded.
However, my scenario is slightly different that the <DIV> box in my page is inserted dynamically with different forms, like Ajax.Updater(‘action_box’, ‘action_form.html’), during the users navigation. So that I cannot rely on setting up onsubmit and onLoad event handlers when the main page is loaded. Here is a slightly modified and simplified version of the one in OpenJS to cater for this scenario. It is imperative that you understand the OpenJS tutorial first. Read more