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

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

J query 01.07.2013