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 Ajax request and also provide the Ajax code.


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 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, 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 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 web server inside the 
Javascript code

We access the server using special objects; we send data and retrieve data.


The XMLHttpRequest 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>

XMLHttpRequest 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 an error. (We’ll see how to do this shortly.)


XMLHttpRequest properties(ready-state)


Ajax-in-php-ready-state


XMLHttpRequest properties(status)





Ajax-in-php-state




XMLHttpRequest Method


abort()
getAllResponseHeaders()
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(){
xhr;
if(window.XMLHttpRequest){
// 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
element
} // end if condition
} // end onreadystatechange
xhr.open("GET" , "form.php" , true) ; // open
method
xhr.send( null ); // finaly sending xhr request
.....
} // formData()
</script>
<a href="javascript:void(0)" onClick="formData()">
click here </a>
<div id="form"></div>

COMMENTS

Name

Blogging,8,How to,21,Make Money,9,SEO,14,Tricks & Tips,1,Web Designing,10,Web Development,6,
ltr
item
Weblog Tricks - Learn Everything About Web : AJAX in php
AJAX in php
What is Ajax in php Jquery AJAX (Asynchronous JavaScript and XML) step by step in php and mysql and also this code tutorial from database
https://3.bp.blogspot.com/-swHvLRQXegw/WKKqd4UuzrI/AAAAAAAAAUs/P9lfs5mPhAIkwf9axPUIDeL9Z1sCA11FwCLcB/s640/Presentation1.jpg
https://3.bp.blogspot.com/-swHvLRQXegw/WKKqd4UuzrI/AAAAAAAAAUs/P9lfs5mPhAIkwf9axPUIDeL9Z1sCA11FwCLcB/s72-c/Presentation1.jpg
Weblog Tricks - Learn Everything About Web
http://www.weblogtricks.com/2017/02/ajax-in-php.html
http://www.weblogtricks.com/
http://www.weblogtricks.com/
http://www.weblogtricks.com/2017/02/ajax-in-php.html
true
3158682668530211189
UTF-8
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