SlideShare une entreprise Scribd logo
1  sur  21
www.consynchro.com
www.consynchro.com
Overview:
•jQueryAjax
•Ajax load()
•Ajax Post/Get()
•noConflict()
www.consynchro.com
Introduction:
AJAX = Asynchronous JavaScript and XML
AJAX is the art of exchanging data with a server, and updating
parts of a web page - without reloading the whole page.
jQuery Ajax:
With the jQuery AJAX methods, you can request text, HTML,
XML, or JSON from a remote server using both HTTP Get and HTTP Post
And you can load the external data directly into the selected HTML
elements of your web page!
www.consynchro.com
jQuery load() Method:
The load() method loads data from a server and puts the
returned data into the selected element.
Syntax:-
$(selector).load(URL,data,callback);
•The required URL parameter specifies the URL you wish to load.
•The optional data parameter specifies a set of querystring key/value pairs to send
along with the request.
•The optional callback parameter is the name of a function to be executed after the
load() method is completed.
Ex:-
www.consynchro.com
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js">
</script>
<script> o/p:1 o/p:2
$(document).ready(function(){
$("button").click(function(){
$("#div1").load("test.txt");
});
});
</script>
</head>
<body>
<div id="div1"><h2>Hello</h2></div>
<button>Get Text from test.txt</button>
</body>
</html>
www.consynchro.com
•It is also possible to add a jQuery selector to the URL parameter.
Ex:-
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").load("test.txt #p1");
});
});
</script>
</head>
<body>
<div id="div1"><h2>Hello</h2></div>
<button>Get Text from Test.txt</button>
</body>
www.consynchro.com
Callback:-
The optional callback parameter specifies a callback function to
run when the load() method is completed. The callback function can
have different parameters:
•responseTxt - contains the resulting content if the call succeed
•statusTxt - contains the status of the call
•xhr - contains the XMLHttpRequest object
www.consynchro.com
Ex:-
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").load("test.4txt ",function(responseTxt,statusTxt,xhr){
if(statusTxt=="success")
alert("External content loaded successfully!");
if(statusTxt=="error")
alert("Error: "+xhr.status+": "+xhr.statusText);
});});});
</script>
</head>
<body>
<div id="div1"><h2>Hello</h2></div>
<button>Get Text from Test.txt</button>
</body>
www.consynchro.com
Output: 1 2
3
HTTP Request: GET vs. POST :
•Two commonly used methods for a request-response between a client
and server are:
GET - Requests data from a specified resource
POST - Submits data to be processed to a specified resource
•GET is basically used for just getting (retrieving) some data from the
server. Note: The GET method may return cached data.
•POST can also be used to get some data from the server. However, the
POST method NEVER caches data, and is often used to send data along
with the request.
www.consynchro.com
jQuery $.get() :
•The $.get() method requests data from the server with an
HTTP GET request.
•Syntax:
$.get(URL,callback);
•The required URL parameter specifies the URL you wish to
request.
•The optional callback parameter is the name of a function to
be executed if the request succeeds.
www.consynchro.com
Example:
<script>
$(document).ready(function(){
$("button").click(function(){
$.get("demo_test.asp",function(data,status){
alert("Data: " + data + "nStatus: " + status);
});
});
});
</script>
www.consynchro.com
•The first parameter of $.get() is the URL we wish to request
("demo_test.asp").
<%response.write("This is some text from an external ASP file.") %>
•The second parameter is a callback function. The first callback
parameter holds the content of the page requested, and the second
callback parameter holds the status of the request.
www.consynchro.com
1
2
jQuery $.post():
•The $.post() method requests data from the server using an
HTTP POST request.
•Syntax:
$.post(URL,data,callback);
www.consynchro.com
Example:
$(document).ready(function(){
$("button").click(function(){
$.post("demo_test_post.asp",
{
name:"Donald Duck",
city:"Duckburg"
},
function(data,status){
alert("Data: " + data + "nStatus: " + status);
}); }); });
www.consynchro.com
•The first parameter of $.post() is the URL we wish to request
("demo_test_post.asp").
•Then we pass in some data to send along with the request
(name and city).
•The ASP script in "demo_test_post.asp" reads the parameters,
process them, and return a result.
•The third parameter is a callback function. The first callback
parameter holds the content of the page requested, and the
second callback parameter holds the status of the request.
www.consynchro.com
aspx file:
<%
dim fname,city
fname=Request.Form("name")
city=Request.Form("city")
Response.Write("Dear " & fname & ". ")
Response.Write("Hope you live well in " & city & ".")
%>
www.consynchro.com
1
2
The jQuery noConflict() :
•The noConflict() method releases the hold on the $ shortcut
identifier, so that other scripts can use it.
•You can of course still use jQuery, simply by writing the full
name instead of the shortcut.
www.consynchro.com
Example:
<script>
$.noConflict();
jQuery(document).ready(function(){
jQuery("button").click(function(){
jQuery("p").text("jQuery is still working!");
});
});
</script>
www.consynchro.com
Example:
<script>
var jq=$.noConflict();
jq(document).ready(function(){
jq("button").click(function(){
jq("p").text("jQuery is still working!");
});
});
</script>
www.consynchro.com
www.consynchro.com

Contenu connexe

Tendances

Introduction tomongodb
Introduction tomongodbIntroduction tomongodb
Introduction tomongodb
Lee Theobald
 
Url Connection
Url ConnectionUrl Connection
Url Connection
phanleson
 

Tendances (19)

Using akka streams to access s3 objects
Using akka streams to access s3 objectsUsing akka streams to access s3 objects
Using akka streams to access s3 objects
 
Reactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwiftReactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwift
 
Introduction tomongodb
Introduction tomongodbIntroduction tomongodb
Introduction tomongodb
 
Get docs from sp doc library
Get docs from sp doc libraryGet docs from sp doc library
Get docs from sp doc library
 
Swift Sequences & Collections
Swift Sequences & CollectionsSwift Sequences & Collections
Swift Sequences & Collections
 
Apache avro and overview hadoop tools
Apache avro and overview hadoop toolsApache avro and overview hadoop tools
Apache avro and overview hadoop tools
 
Public class form1
Public class form1Public class form1
Public class form1
 
wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?
 
laravel-53
laravel-53laravel-53
laravel-53
 
Json
JsonJson
Json
 
Url Connection
Url ConnectionUrl Connection
Url Connection
 
Url Connection
Url ConnectionUrl Connection
Url Connection
 
Modulo para conectar un programa en vb 6
Modulo para conectar un programa en vb 6Modulo para conectar un programa en vb 6
Modulo para conectar un programa en vb 6
 
Mongo db basics
Mongo db basicsMongo db basics
Mongo db basics
 
Full metal mongo
Full metal mongoFull metal mongo
Full metal mongo
 
Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Webエンジニアから見たiOS5
Webエンジニアから見たiOS5
 
Model-View-Update, and Beyond!
Model-View-Update, and Beyond!Model-View-Update, and Beyond!
Model-View-Update, and Beyond!
 
dfl
dfldfl
dfl
 
Sekilas PHP + mongoDB
Sekilas PHP + mongoDBSekilas PHP + mongoDB
Sekilas PHP + mongoDB
 

En vedette

Automationcontrol1
Automationcontrol1Automationcontrol1
Automationcontrol1
liyanagek
 

En vedette (14)

J query 01.07.2013.html
J query 01.07.2013.htmlJ query 01.07.2013.html
J query 01.07.2013.html
 
Automationcontrol1
Automationcontrol1Automationcontrol1
Automationcontrol1
 
Physiology of local anasthesia
Physiology of local anasthesiaPhysiology of local anasthesia
Physiology of local anasthesia
 
Pit and fissure
Pit and fissurePit and fissure
Pit and fissure
 
The armamentarium of local anasthesi
The armamentarium of local anasthesiThe armamentarium of local anasthesi
The armamentarium of local anasthesi
 
Trigeminal nerve anatomy
Trigeminal nerve anatomyTrigeminal nerve anatomy
Trigeminal nerve anatomy
 
Treatment of midface fracture
Treatment of midface fractureTreatment of midface fracture
Treatment of midface fracture
 
Techniques for local anasthesia in dentistry
Techniques for local anasthesia in dentistryTechniques for local anasthesia in dentistry
Techniques for local anasthesia in dentistry
 
Management of cleft lip &amp; palate
Management of cleft lip &amp; palateManagement of cleft lip &amp; palate
Management of cleft lip &amp; palate
 
Complications of teeth extraction
Complications of teeth extractionComplications of teeth extraction
Complications of teeth extraction
 
Cysts in orofacial region
Cysts in orofacial regionCysts in orofacial region
Cysts in orofacial region
 
Facial nerve injury and reanimation
Facial nerve injury and reanimationFacial nerve injury and reanimation
Facial nerve injury and reanimation
 
Complications of local anasthesia in dentistry
Complications of local anasthesia in dentistryComplications of local anasthesia in dentistry
Complications of local anasthesia in dentistry
 
Gunshot wounds
Gunshot woundsGunshot wounds
Gunshot wounds
 

Similaire à J query 01.07.2013

Ajaxtechnicalworkshopshortversion 1224845432835700-8
Ajaxtechnicalworkshopshortversion 1224845432835700-8Ajaxtechnicalworkshopshortversion 1224845432835700-8
Ajaxtechnicalworkshopshortversion 1224845432835700-8
anuradha raheja
 
jQuery : Talk to server with Ajax
jQuery : Talk to server with AjaxjQuery : Talk to server with Ajax
jQuery : Talk to server with Ajax
Wildan Maulana
 

Similaire à J query 01.07.2013 (20)

jQuery - Chapter 5 - Ajax
jQuery - Chapter 5 -  AjaxjQuery - Chapter 5 -  Ajax
jQuery - Chapter 5 - Ajax
 
Ajax for dummies, and not only.
Ajax for dummies, and not only.Ajax for dummies, and not only.
Ajax for dummies, and not only.
 
Ajax.ppt
Ajax.pptAjax.ppt
Ajax.ppt
 
Unit-5.pptx
Unit-5.pptxUnit-5.pptx
Unit-5.pptx
 
Ajax
AjaxAjax
Ajax
 
JSON and XML
JSON and XMLJSON and XML
JSON and XML
 
Ajaxtechnicalworkshopshortversion 1224845432835700-8
Ajaxtechnicalworkshopshortversion 1224845432835700-8Ajaxtechnicalworkshopshortversion 1224845432835700-8
Ajaxtechnicalworkshopshortversion 1224845432835700-8
 
Ajax
AjaxAjax
Ajax
 
J Query Presentation of David
J Query Presentation of DavidJ Query Presentation of David
J Query Presentation of David
 
AJAX.ppt
AJAX.pptAJAX.ppt
AJAX.ppt
 
Ajax chap 4
Ajax chap 4Ajax chap 4
Ajax chap 4
 
AJAX.pptx
AJAX.pptxAJAX.pptx
AJAX.pptx
 
jQuery : Talk to server with Ajax
jQuery : Talk to server with AjaxjQuery : Talk to server with Ajax
jQuery : Talk to server with Ajax
 
AJAX.pptx
AJAX.pptxAJAX.pptx
AJAX.pptx
 
JavaScript JQUERY AJAX
JavaScript JQUERY AJAXJavaScript JQUERY AJAX
JavaScript JQUERY AJAX
 
Ajax
AjaxAjax
Ajax
 
Web 11 | AJAX + JSON + PHP
Web 11 | AJAX + JSON + PHPWeb 11 | AJAX + JSON + PHP
Web 11 | AJAX + JSON + PHP
 
What's new in jQuery 1.5
What's new in jQuery 1.5What's new in jQuery 1.5
What's new in jQuery 1.5
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Ajax tutorial by bally chohan
Ajax tutorial by bally chohanAjax tutorial by bally chohan
Ajax tutorial by bally chohan
 

Dernier

TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
Muhammad Subhan
 
Microsoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdfMicrosoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdf
Overkill Security
 

Dernier (20)

Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Microsoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdfMicrosoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdf
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 

J query 01.07.2013