Basic Question for Ajax Gurus
I’m working on upgrading a contact form tonight to include simple Ajax functionality within a WordPress theme. Its actually the Ajax from Chapter 5 of Jeremy Keith’s Bulletproof Ajax and my own contact form and server side processing. Not for this site though.
What I’ve done is probably a bit of a fudge. Like Jeremy’s model the String saying required is inserted into the form labels of fields that don’t have content, that’s easy enough. And the string is returned to the form via simple URL encoding (don’t ask me why I tacked it on that way). Yes the URL encoding actually just identifies label X to say required. Not a big deal. My apologies for not showing you but its located on an intranet behind a proxy firewall.
The Ajax works (in a fashion) and thanks to Jeremy’s code for that one. But there’s also an issue that’s got me scratching my head. And its got me wondering if any Ajax gurus might be passing tonight willing to offer a word of advice to a self-confessed JavaScript kludge.
The problem is that form submissions are going in and then the Ajax is inserting an entire new page into the #content div, not just updating the form labels to show required. If that makes sense? Now, my question is twofold. Why is this returning the whole page? And, more importantly, how would I subvert that to only return the necessary form? Because I thought it was going to do exactly that.








May 18th, 2008 at 9:03 pm
Ha ha ha that’s the trouble when you’re doing a huge amount of Quality Assurance (about 12 to 16 hours on five huge forms of radio button selections for some reason kept in case statements - don’t ask me why - of a different list for each possible selection). The QA, my paid work and then trying to work on the Ajax.
So nobody threw stones… but then if I’m calling an entire page into the #content div then of course I’m getting a page within a page (a bit red sorry).
Rewrite the PHP and I’ll be away… problem solvered.