Monday, November 1, 2010

Implementing AJAX

In the last post, we have learnt that what is AJAX.
Now in this post, we will implement it using PHP.
 The only important thing at the moment is that AJAX uses JavaScript so it needs to be enabled in your browser to successfully implement it.
To demonstrate the AJAX PHP connection we will create a very simple form with 2 input fields.
In the first field you can type any text and we will send this text to our PHP script which will convert it to uppercase and sends it back to us. At the end we will put the result into the second input field.
Let us see some simple html code:
<html>
<head><title>Ajax - PHP example</title>
</head>
<body>
<form name="testForm">
 Input text: <input type="text"  onkeyup="doWork();" name="inputText" id="inputText" />
 Output text: <input type="text" name="outputText" id="outputText" />
 </form>
</body>
</html>