What is Ajax and how to use Ajax in PHP?


Today's Post about Ajax PHP mean (Asynchronous Javascript and XML.) this is also part of  PHP Web development,

In This Tutorial, I will tell you Ajax property and it is an Ajax request and also provide the Ajax code. and  What is the use of  ajax in PHP

What is Ajax and how to use Ajax in PHP?

What is Ajax and how to use Ajax in PHP?

Ajax means (Asynchronous Javascript and XML.)  Ajax PHP is not a stand-alone language or technology it's a technique that combines a set of known technologies in order to create faster and more user-friendly web pages.

because It's a client-side technology simply the main purpose of Ajax PHP that prevents unnecessary reloading of a page.

When we submit a form, although most of the page remains the same, the whole page is reloaded from the server this causes very long waiting for times and waste of bandwidth.

AJAX PHP aims at loading only the necessary information and making only the necessary changes on the current page without reloading the whole page.

AJAX PHP uses the following technologies

* Javascript Ajax (for altering the page)
* XML (for information exchange)
* PHP Ajax or JSP (server-side)
Ajax (sometimes written AJAX) is a means of using JavaScript  Ajax to communicate with a web server without submitting a form or loading a new page.

AJAX is based on Javascript Ajax, and the main functionality is to access the webserver inside the 
Javascript code.  we access the server using special objects; we send data and retrieve data.

The XML Http Request object

The XMLHttpRequest object is the backbone of every Ajax method. Each application requires the
creation of one of these objects. So how do we do it? 

Firefox, Safari, Opera and some other browsers can create one of these objects simply using the 
“new” keyword.

<script type="text/javascript">
ajaxRequest = new XMLHttpRequest(); </script>

XML Http Request object properties

ajax in php

We use the ready-state to determine when the request has been completed, and then check the
status to see if it executed without any error. (We’ll see how to do this shortly.)

XML Http Request properties(ready-state)


XML Http Request properties(status)


XML Http Request Method

getResponseHeader( “headername” )
open(“method” , “url” async );

-open( “GET” , “myfile.php” , true )
send( content )
setRequestHeader( “label” , “value” )

you can also read the following post.

Error Reporting 
Calculator in Php


Ajax code

<script type="application/javascript">
function formData(){
// checking browser like chrome , firefox etc......
xhr = new XMLHttpRequest(); // creating object of XMLHttpRequest
} else {
// code for IE6, IE5
xhr= new ActiveXObject("Microsoft.XMLHTTP");
xhr.onreadystatechange = function(){
// onreadystatechange event with js function which has no name
// but onreadystatechange check readystate value like 0 , 1, .... 4
if( xhr.readyState == 4 && xhr.status == 200 )
// if condition ~ 404 page not found ~ 200 page exist
document.getElementById( "form" ).innerHTML =
xhr.responseText ;
// xhr response text inserting in html
} // end if condition
} // end onreadystatechange
xhr.open("GET" , "form.php" , true) ; // open
xhr.send( null ); // finaly sending xhr request
} // formData()
<a href="javascript:void(0)" onClick="formData()">
click here </a>
<div id="form"></div>



Blogging,15,C Language,3,How to,26,Make Money,11,SEO,27,Web Development,24,
Weblog Tricks - Helping You Succeed To Become an entrepreneur: What is Ajax and how to use Ajax in PHP?
What is Ajax and how to use Ajax in PHP?
What is Ajax in php Jquery AJAX (Asynchronous JavaScript and XML) step by step in php and mysql and What is Ajax and how to use Ajax in PHP?
Weblog Tricks - Helping You Succeed To Become an entrepreneur
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy