SlideShare a Scribd company logo
Ajax
muhammadabaloch
What is AJAX ?
• Asynchronous Javascript and XML.
• Not a stand-alone language or technology.
• It is a technique that combines a set of known technologies in order to create
faster and more user friendly web pages.
• It is a client side technology.
muhammadabaloch
Purpose of AJAX
• 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 times and waste of bandwidth.
• AJAX aims at loading only the necessary information, and making only the
necessary changes on the current page without reloading the whole page.
muhammadabaloch
Technologies Used
• AJAX uses:
• Javascript (for altering the page)
• XML (for information exchange)
• PHP or JSP (server side)
muhammadabaloch
Simple Processing
• Ajax (sometimes written AJAX) is a means of using JavaScript to communicate
with a web server without submitting a form or loading a new page.
• AJAX is based on Javascript, and the main functionality is to access the web
server inside the Javascript code.
• We access to the server using special objects; we send data and retrieve data.
muhammadabaloch
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>
muhammadabaloch
XMLHttpRequest object properties
We use the readyState to determine when the request has been completed, and then check the status to se if
it executed without an error. (We’ll see how to do this shortly.)
muhammadabaloch
Property Description
readyState An integer from 0. . .4. (0 means the call is uninitialized, 4 means that the call is complete.)
onreadystatechange Determines the function called when the objects readyState changes.
responseText Data returned from the server as a text string (read-only).
responseXML Data returned from the server as an XML document object (read-only).
status HTTP status code returned by the server
statusText HTTP status phrase returned by the server
XMLHttpRequest properties(readyState)
muhammadabaloch
Value Definition
0 Uninitialized
-Object contains no data
1 Loading
-Object is currently loading its data
2 Loaded
-Object has finished loading its data
3 Interactive
-User may interact with the object even though it’s not fully loaded
4 Complete
-Object has finished initializing
XMLHttpRequest properties(status)
• Event Handler
- onreadystatechange
muhammadabaloch
Value Definition
200 Ok
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
500 Internal Server Error
XMLHttpRequest Method
• abort()
• getAllResponseHeaders()
• getResponseHeader( “headername” )
• open(“method” , “url” async );
-open( “GET” , “myfile.php” , true )
• send( content )
• setRequestHeader( “label” , “value” )
muhammadabaloch
Ajax code
<script type="application/javascript">
function formData(){
xhr = undefined ;
if(window.XMLHttpRequest){
// checking browser like chrome , firefox etc......
xhr = new XMLHttpRequest(); // creating object of XMLHttpRequest
}
xhr.onreadystatechange = function(){
// onreadystatechange event with js function which has no name
// but onreadystatechange check readystate value like 0 , 1, .... 4
muhammadabaloch
Ajax code (cont’)
if( xhr.readyState == 4 && xhr.status == 404 ){
// 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("POST" , "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>
muhammadabaloch

More Related Content

What's hot

Ajax & Reverse Ajax Presenation
Ajax & Reverse Ajax PresenationAjax & Reverse Ajax Presenation
Ajax & Reverse Ajax Presenation
Rishabh Garg
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
Raja V
 
Ajax ppt - 32 slides
Ajax ppt - 32 slidesAjax ppt - 32 slides
Ajax ppt - 32 slides
Smithss25
 
Ajax Patterns : Periodic Refresh & Multi Stage Download
Ajax Patterns : Periodic Refresh & Multi Stage DownloadAjax Patterns : Periodic Refresh & Multi Stage Download
Ajax Patterns : Periodic Refresh & Multi Stage Download
Eshan Mudwel
 
ITI006En-AJAX
ITI006En-AJAXITI006En-AJAX
ITI006En-AJAX
Huibert Aalbers
 
AJAX
AJAXAJAX
Ajax Presentation
Ajax PresentationAjax Presentation
Ajax Presentationronaldmam
 
Ajaxcom
AjaxcomAjaxcom
Ajaxcom
vurimi prasad
 
Ajax
AjaxAjax
25250716 seminar-on-ajax text
25250716 seminar-on-ajax text25250716 seminar-on-ajax text
25250716 seminar-on-ajax text
Kamleshh Chandnani
 
Xml and webservice
Xml and webserviceXml and webservice
Xml and webservice
saba sumreen
 
Jsp & Ajax
Jsp & AjaxJsp & Ajax
Jsp & Ajax
Ang Chen
 
ajax - the basics
ajax - the basicsajax - the basics
ajax - the basics
Arnelle Balane
 

What's hot (20)

Ajax & Reverse Ajax Presenation
Ajax & Reverse Ajax PresenationAjax & Reverse Ajax Presenation
Ajax & Reverse Ajax Presenation
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
2310 b 13
2310 b 132310 b 13
2310 b 13
 
Ajax
AjaxAjax
Ajax
 
Ajax ppt - 32 slides
Ajax ppt - 32 slidesAjax ppt - 32 slides
Ajax ppt - 32 slides
 
AJAX
AJAXAJAX
AJAX
 
Ajax Patterns : Periodic Refresh & Multi Stage Download
Ajax Patterns : Periodic Refresh & Multi Stage DownloadAjax Patterns : Periodic Refresh & Multi Stage Download
Ajax Patterns : Periodic Refresh & Multi Stage Download
 
ITI006En-AJAX
ITI006En-AJAXITI006En-AJAX
ITI006En-AJAX
 
AJAX
AJAXAJAX
AJAX
 
Ajax
AjaxAjax
Ajax
 
Ajax Presentation
Ajax PresentationAjax Presentation
Ajax Presentation
 
Ajax
AjaxAjax
Ajax
 
Ajaxcom
AjaxcomAjaxcom
Ajaxcom
 
Ajax
AjaxAjax
Ajax
 
Introduction to AJAX
Introduction to AJAXIntroduction to AJAX
Introduction to AJAX
 
Ajax and ASP.NET AJAX
Ajax and ASP.NET AJAXAjax and ASP.NET AJAX
Ajax and ASP.NET AJAX
 
25250716 seminar-on-ajax text
25250716 seminar-on-ajax text25250716 seminar-on-ajax text
25250716 seminar-on-ajax text
 
Xml and webservice
Xml and webserviceXml and webservice
Xml and webservice
 
Jsp & Ajax
Jsp & AjaxJsp & Ajax
Jsp & Ajax
 
ajax - the basics
ajax - the basicsajax - the basics
ajax - the basics
 

Similar to Ajax

AJAX.pptx
AJAX.pptxAJAX.pptx
AJAX.pptx
Ganesh Chavan
 
Unit-5.pptx
Unit-5.pptxUnit-5.pptx
Unit-5.pptx
itzkuu01
 
Ajax tutorial by bally chohan
Ajax tutorial by bally chohanAjax tutorial by bally chohan
Ajax tutorial by bally chohan
WebVineet
 
Ajax
AjaxAjax
PHP - Introduction to PHP AJAX
PHP -  Introduction to PHP AJAXPHP -  Introduction to PHP AJAX
PHP - Introduction to PHP AJAX
Vibrant Technologies & Computers
 
Ajax and xml
Ajax and xmlAjax and xml
Ajax and xml
sawsan slii
 
Ajax
AjaxAjax
Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)
Adnan Sohail
 
WEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptxWEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptx
karthiksmart21
 
Ajax
AjaxAjax
Ajax presentation
Ajax presentationAjax presentation
Ajax presentation
engcs2008
 

Similar to Ajax (20)

AJAX.pptx
AJAX.pptxAJAX.pptx
AJAX.pptx
 
Ajax
AjaxAjax
Ajax
 
Unit-5.pptx
Unit-5.pptxUnit-5.pptx
Unit-5.pptx
 
Ajax Tuturial
Ajax TuturialAjax Tuturial
Ajax Tuturial
 
Ajax
AjaxAjax
Ajax
 
Ajax tutorial by bally chohan
Ajax tutorial by bally chohanAjax tutorial by bally chohan
Ajax tutorial by bally chohan
 
Ajax
AjaxAjax
Ajax
 
Ajax
Ajax Ajax
Ajax
 
PHP - Introduction to PHP AJAX
PHP -  Introduction to PHP AJAXPHP -  Introduction to PHP AJAX
PHP - Introduction to PHP AJAX
 
Ajax
AjaxAjax
Ajax
 
Ajax and xml
Ajax and xmlAjax and xml
Ajax and xml
 
Ajax
AjaxAjax
Ajax
 
Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
WEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptxWEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptx
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
Ajax presentation
Ajax presentationAjax presentation
Ajax presentation
 

More from Mudasir Syed

Error reporting in php
Error reporting in php Error reporting in php
Error reporting in php
Mudasir Syed
 
Cookies in php lecture 2
Cookies in php  lecture  2Cookies in php  lecture  2
Cookies in php lecture 2
Mudasir Syed
 
Cookies in php lecture 1
Cookies in php lecture 1Cookies in php lecture 1
Cookies in php lecture 1
Mudasir Syed
 
Reporting using FPDF
Reporting using FPDFReporting using FPDF
Reporting using FPDF
Mudasir Syed
 
Oop in php lecture 2
Oop in  php lecture 2Oop in  php lecture 2
Oop in php lecture 2
Mudasir Syed
 
Oop in php lecture 2
Oop in  php lecture 2Oop in  php lecture 2
Oop in php lecture 2
Mudasir Syed
 
Filing system in PHP
Filing system in PHPFiling system in PHP
Filing system in PHP
Mudasir Syed
 
Time manipulation lecture 2
Time manipulation lecture 2Time manipulation lecture 2
Time manipulation lecture 2
Mudasir Syed
 
Time manipulation lecture 1
Time manipulation lecture 1 Time manipulation lecture 1
Time manipulation lecture 1
Mudasir Syed
 
Php Mysql
Php Mysql Php Mysql
Php Mysql
Mudasir Syed
 
Adminstrating Through PHPMyAdmin
Adminstrating Through PHPMyAdminAdminstrating Through PHPMyAdmin
Adminstrating Through PHPMyAdmin
Mudasir Syed
 
PHP mysql Sql
PHP mysql  SqlPHP mysql  Sql
PHP mysql Sql
Mudasir Syed
 
PHP mysql Mysql joins
PHP mysql  Mysql joinsPHP mysql  Mysql joins
PHP mysql Mysql joins
Mudasir Syed
 
PHP mysql Introduction database
 PHP mysql  Introduction database PHP mysql  Introduction database
PHP mysql Introduction database
Mudasir Syed
 
PHP mysql Installing my sql 5.1
PHP mysql  Installing my sql 5.1PHP mysql  Installing my sql 5.1
PHP mysql Installing my sql 5.1
Mudasir Syed
 
PHP mysql Er diagram
PHP mysql  Er diagramPHP mysql  Er diagram
PHP mysql Er diagram
Mudasir Syed
 
PHP mysql Database normalizatin
PHP mysql  Database normalizatinPHP mysql  Database normalizatin
PHP mysql Database normalizatin
Mudasir Syed
 
PHP mysql Aggregate functions
PHP mysql Aggregate functionsPHP mysql Aggregate functions
PHP mysql Aggregate functions
Mudasir Syed
 
Form validation with built in functions
Form validation with built in functions Form validation with built in functions
Form validation with built in functions
Mudasir Syed
 

More from Mudasir Syed (20)

Error reporting in php
Error reporting in php Error reporting in php
Error reporting in php
 
Cookies in php lecture 2
Cookies in php  lecture  2Cookies in php  lecture  2
Cookies in php lecture 2
 
Cookies in php lecture 1
Cookies in php lecture 1Cookies in php lecture 1
Cookies in php lecture 1
 
Reporting using FPDF
Reporting using FPDFReporting using FPDF
Reporting using FPDF
 
Oop in php lecture 2
Oop in  php lecture 2Oop in  php lecture 2
Oop in php lecture 2
 
Oop in php lecture 2
Oop in  php lecture 2Oop in  php lecture 2
Oop in php lecture 2
 
Filing system in PHP
Filing system in PHPFiling system in PHP
Filing system in PHP
 
Time manipulation lecture 2
Time manipulation lecture 2Time manipulation lecture 2
Time manipulation lecture 2
 
Time manipulation lecture 1
Time manipulation lecture 1 Time manipulation lecture 1
Time manipulation lecture 1
 
Php Mysql
Php Mysql Php Mysql
Php Mysql
 
Adminstrating Through PHPMyAdmin
Adminstrating Through PHPMyAdminAdminstrating Through PHPMyAdmin
Adminstrating Through PHPMyAdmin
 
Sql select
Sql select Sql select
Sql select
 
PHP mysql Sql
PHP mysql  SqlPHP mysql  Sql
PHP mysql Sql
 
PHP mysql Mysql joins
PHP mysql  Mysql joinsPHP mysql  Mysql joins
PHP mysql Mysql joins
 
PHP mysql Introduction database
 PHP mysql  Introduction database PHP mysql  Introduction database
PHP mysql Introduction database
 
PHP mysql Installing my sql 5.1
PHP mysql  Installing my sql 5.1PHP mysql  Installing my sql 5.1
PHP mysql Installing my sql 5.1
 
PHP mysql Er diagram
PHP mysql  Er diagramPHP mysql  Er diagram
PHP mysql Er diagram
 
PHP mysql Database normalizatin
PHP mysql  Database normalizatinPHP mysql  Database normalizatin
PHP mysql Database normalizatin
 
PHP mysql Aggregate functions
PHP mysql Aggregate functionsPHP mysql Aggregate functions
PHP mysql Aggregate functions
 
Form validation with built in functions
Form validation with built in functions Form validation with built in functions
Form validation with built in functions
 

Recently uploaded

Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 

Recently uploaded (20)

Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 

Ajax

  • 2. What is AJAX ? • Asynchronous Javascript and XML. • Not a stand-alone language or technology. • It is a technique that combines a set of known technologies in order to create faster and more user friendly web pages. • It is a client side technology. muhammadabaloch
  • 3. Purpose of AJAX • 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 times and waste of bandwidth. • AJAX aims at loading only the necessary information, and making only the necessary changes on the current page without reloading the whole page. muhammadabaloch
  • 4. Technologies Used • AJAX uses: • Javascript (for altering the page) • XML (for information exchange) • PHP or JSP (server side) muhammadabaloch
  • 5. Simple Processing • Ajax (sometimes written AJAX) is a means of using JavaScript to communicate with a web server without submitting a form or loading a new page. • AJAX is based on Javascript, and the main functionality is to access the web server inside the Javascript code. • We access to the server using special objects; we send data and retrieve data. muhammadabaloch
  • 6. 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> muhammadabaloch
  • 7. XMLHttpRequest object properties We use the readyState to determine when the request has been completed, and then check the status to se if it executed without an error. (We’ll see how to do this shortly.) muhammadabaloch Property Description readyState An integer from 0. . .4. (0 means the call is uninitialized, 4 means that the call is complete.) onreadystatechange Determines the function called when the objects readyState changes. responseText Data returned from the server as a text string (read-only). responseXML Data returned from the server as an XML document object (read-only). status HTTP status code returned by the server statusText HTTP status phrase returned by the server
  • 8. XMLHttpRequest properties(readyState) muhammadabaloch Value Definition 0 Uninitialized -Object contains no data 1 Loading -Object is currently loading its data 2 Loaded -Object has finished loading its data 3 Interactive -User may interact with the object even though it’s not fully loaded 4 Complete -Object has finished initializing
  • 9. XMLHttpRequest properties(status) • Event Handler - onreadystatechange muhammadabaloch Value Definition 200 Ok 400 Bad Request 401 Unauthorized 403 Forbidden 404 Not Found 500 Internal Server Error
  • 10. XMLHttpRequest Method • abort() • getAllResponseHeaders() • getResponseHeader( “headername” ) • open(“method” , “url” async ); -open( “GET” , “myfile.php” , true ) • send( content ) • setRequestHeader( “label” , “value” ) muhammadabaloch
  • 11. Ajax code <script type="application/javascript"> function formData(){ xhr = undefined ; if(window.XMLHttpRequest){ // checking browser like chrome , firefox etc...... xhr = new XMLHttpRequest(); // creating object of XMLHttpRequest } xhr.onreadystatechange = function(){ // onreadystatechange event with js function which has no name // but onreadystatechange check readystate value like 0 , 1, .... 4 muhammadabaloch
  • 12. Ajax code (cont’) if( xhr.readyState == 4 && xhr.status == 404 ){ // 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("POST" , "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> muhammadabaloch