Our friend David had some time on his hands and a great idea for a web app: that's the recipe for success. Wanting to concentrate on the PHP back-end, he brought in a friend to develop the AJAX front-end.
Unfortunately, things started to get thorny when it came to connecting the two. The browser-side demo looked great but all the forms were submitting data through GET instead of POST. This was a major problem for the application, so David got a shovel and dug into the "AJAX".
Here's what he found.
<form id="form" action="javascript:postLine(document.getElementById('form').msg.value);" > <input type="text" name="msg" size="80" /> <input type="submit" name="form" value="Send" /> </form>
Maybe that wasn't the best use of action but this was just a prototype; they could fix it later. The real question was: what does postLine do?
function postLine(text) { var url = "send.php?msg=" + text; url = base_url + url; var jsel = document.createElement('SCRIPT'); jsel.type = 'text/javascript'; jsel.src = url; document.body.appendChild(jsel); document.getElementById('form').msg.value=''; }
To quote David: "Not the AJAX you would expect is it?" It's probably worth mentioning --- before anyone gets any bright ideas --- that "send.php" doesn't return JavaScript.