Ajax with webSPELL-Function "fetch"

Ajax is a big topic at the moment. I didn't really get into it because I thought it was very difficult. It might be but webSPELL makes it very easy.
I suggest you Download the Ajax Comments Validator. It will make it easier to understand whats going on.
Now that you've got the Ajax-Validation running, lets take a look at the way it works.
HTML
Everything starts with an input.I'm going to show you how it works with the Homepage/URL-Input.
Our HTML-Code looks like this: (See templates/comments_add_visitors.html)
As you see I've added a span-Tag after the input - with an ID. However, the more important part is this:
We use the Javascript Event onblur, it calls the function checkhomepage() whenever the User takes the foces off the input.
Javascript
You can find the Javascript in templates/comments_add_visitors.htmlLets break it down.
This just replaces the Content of the span-Tag with the id="validateHomepage" with the
-Icon.As explained in the graphic on top, there are 4 parameter that are necessary.
URL
direct.php will be called, with the parameters:
action=check_url
homepage=the-value-entered-in-the-input
The direct.php will accept this parameters, call the correct PHP-Function and return a String.
ID
"The ID of the Element we want to manipulate" is pretty much all there is to say about this parameter. We want to manipulate the span-Tag with the id "validateHomepage"ACTION
We've got 4 options here. add, replace, execute and formfield. We want to replace the Content of the span-Tag, with the String the PHP-Script (direct.php) returns.
BASE
time or event, we are using it event-based. As said before we are using an Javascript Event.
If you want to call the fetch-function time-based you've got to add the 5th, optional, parameter - milliseconds. Tweet
Your comment
