In how many ways we can use ajax in JQuery library

December 28, 2009 | Filed Under PHP | Comments Off

There are number of ways to use Ajax in JQuery library

GET Oriented Method:
If you want Ajax activity either on load page, submit form, paging what ever. It depend on you
Use below code


$. get (“back.php”, {name1: “php”, name2: “interview”},
function(data){
alert(“Data Loaded: ” + data);
});

Where
back.php = back file need to call.
name1: “php”, name1: “interview” = values to send on back.php.
data = value which back.php will return.

Please see look on back.php

POST Oriented Method:

Please changes $.get to $.post in above code.

Third method:

This is third method to use Ajax using JQuery library.

$.ajax({
type: “POST”,
Url: “back.php”,
data: “name=php&location=India”,
success:function (msg){
alert( “Data Saved: ” + msg);
}
});

Comments

Comments are closed.

© PHPInterviewQuestion.com 2009 - 2012

eXTReMe Tracker