Angelo's Corner

PHP and AJAX

May 26, 2010

Ajax (shorthand for asynchronous JavaScript and XML[1]) is a group of interrelated web development techniques used on the client-side to create interactive web applications.

-we use AJAX for the dynamic controls of our web applications…so this is morely on the client side of the application..

and the server side language is PHP..

so combining the two we can build a several web applications…isn’t it?..

 

so that is why…

i have a very simple program demonstrating the PHP and AJAX coding..

 

 1. assuming we have file test.php

 <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Reverse using Ajax</title>
</head>
<script language=”javascript”>
    function doReverse(){
        var str=document.getElementById(”txtStr”).value;
        var httpObject=getHTTPObject();
        if(httpObject!=null){
            httpObject.open(”GET”,”reverse.php?str=”+str,true);
            httpObject.send(null);
            httpObject.onreadystatechange=
                function updateReverse(){
                    var responseStr;
                    if(httpObject.readyState==4){
                        responseStr=httpObject.responseText;
                        document.getElementById(”txtReverse”).value=responseStr;
                        document.getElementById(”txtStr”).value=responseStr;
                    }                
                }
            
       
        }
       
    }
   
    function getHTTPObject(){
        if(window.ActiveXObject)
            return new ActiveXObject(”Microsoft.XMLHTTP”);           
        else if(window.XMLHttpRequest)
            return new XMLHttpRequest();
        else{
            alert(”Your browser does not support AJAX”);
            return null;
        }
       
       
    }
</script>

<body>
<table width=”392″ border=”0″ cellspacing=”0″ cellpadding=”0″>
  <tr>
    <td width=”184″>String:</td>
    <td width=”208″><input id=”txtStr” type=”text” size=”40″ /></td>
  </tr>
  <tr>
    <td>String in Reverse:</td>
    <td><input name=”text” type=”text” id=”txtReverse” size=”40″ /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type=”button” name=”cmdReverse” value=”Reverse” onclick=”doReverse();” /></td>
  </tr>
</table>
</body>

</html>

 

 2.we have also file reverse.php

<?php
   
$str=$_GET[”str”];
echo strrev($str);

?>

 

so this is the very simple way implementing AJAX in PHP..

hope it helps..

 

 

Posted by angelohere at 2:38 pm | permalink | Add comment

     

May 2010
M T W T F S S
« Nov    
 12
3456789
10111213141516
17181920212223
24252627282930
31  

About Me

I am Angelo F. Matildo, my nickname is ngel. Currently, I am a developer/programmer who loves to explore things. This blog is primarily for me to post my researches,my some learnings,sharing and some random ideas. Most likely I'm not going to be commenting on things happening... As such it will most likely not be updated very often...

Message Board

Informasi Kredit Terbaik di Indonesia:

http://en.wuryantoro.com/2012/01/informasi-kredit-terbaik-di-indonesia.html
http://www.wuryantoro.com/2012/01/informasi-kredit-terbaik-di-indonesia.html

seribu pernak pernik ponsel android:

thank gan …

guest:

http://h-e-r-u.blogspot.com/2012/01/musholla-negeri-dongeng.html
http://h-e-r-u.blogspot.com/2012/01/konte-seo-informasi-kredit-terbaik-di.html

guest:

http://h-e-r-u.blogspot.com/2012/01/dongeng-bahasa-jawa-kancil-dan-merak.html
http://h-e-r-u.blogspot.com/2012/01/dongeng-bahasa-jawa-cinderella.html
http://h-e-r-u.blogspot.com/2011/10/foto-video-pe-remas-payudara-wanita.html

h-e-r-u:

http://h-e-r-u.blogspot.com/2011/10/bisnis-online-daftar-gratis-bonus.html
http://h-e-r-u.blogspot.com/2011/11/software-akuntansi.html
http://h-e-r-u.blogspot.com/2011/12/sekolah-manajemen-perhotelan-ihs.html
http://h-e-r-u.blogspot.com/2012/01/dongeng-bahasa-jawa-kancil-dan-merak.html
http://h-e-r-u.blogspot.com/2012/01/dongeng-bahasa-jawa-cinderella.html
http://h-e-r-u.blogspot.com/2011/10/foto-video-pe-remas-payudara-wanita.html

Software Akuntansi Laporan Keuangan Terbaik:

http://blogbudaqdegil.blogspot.com/2012/01/akuntansi-laporan-keuangan-terbaik.html

software akuntansi laporan keuangan terbaik:


Its my first visit, please come to my blog

kord gitar Ebiet G. Ade:

http://gitarchordshack.blogspot.com/2010/11/camelia-iii-ebiet-g-ade.html
http://blogbudaqdegil.blogspot.com/2011/12/tips-merawat-baterai-laptop.html

Ian:

Sir my usb is unable to open my but my is already there so i download the link this..ToggleVBScript for torrent still unable to down. SO pls help of to run this application. thanks

Ultrabook Notebook Tipis Harga Murah Terbaik:

thanks..really helpful..

Ultrabook Notebook Tipis Harga Murah Terbaik:

thanks..really helpful..

Harga Notebook:

http://tipshealthbeauty.org/ultrabook-notebook-tipis-harga-murah-terbaik/

Ultrabook Notebook Tipis Harga Murah Terbaik:

http://tipshealthbeauty.org/ultrabook-notebook-tipis-harga-murah-terbaik/

Arif Poetra Yunar Blog:

Nice website
http://arifpoetrayunar.blogspot.com/2011/12/software-akuntansi-laporan-keuangan.html
http://arifpoetrayunar.blogspot.com/2011/12/ultrabook-notebook-tipis-harga-murah.html

cwiter:

thank’s you,, ^_^

http://cwiter.blogspot.com

Download Anima Gratis:

http://animakugratis.blogspot.com

Download Anima Gratis:

Animakugratis.blogspot.com is a blog that provides a variety of exciting animated films such as naruto, bleach, Beelzebub, one piece and many others. For the lovers of anima do not hesitate to visit in animakugratis.blogspot.com datng. You can also watch it online free no charge at all

Download Anima Gratis:

Animakugratis.blogspot.com is a blog that provides a variety of exciting animated films such as naruto, bleach, Beelzebub, one piece and many others. For the lovers of anima do not hesitate to visit in animakugratis.blogspot.com datng. You can also watch it online free no charge at all

Cara Menghilangkan Jerawat:

sip

VIAR Motor Indonesia:

http://firmanstatistisi.blog.com/viar-motor-indonesia/

Leave a message ▼

Sponsored Links

Latest Comments

Strange Google Maps

Subscribe

Technorati
Bloglines