Here is the simple example of YUI ajax with Post and Get method:
POST request:
var callback = {
success: function(o){
alert(o.responseText);
},
failure: function(o){
alert('Unable to connect to server.');
},
cache: false
}
var url = 'my_url?id=1';
YAHOO.util.Connect.asyncRequest('POST', url, callback);
GET request
var callback = {
success: function(o){
alert(o.responseText);
},
failure: function(o){
alert('Unable to connect to server.');
},
cache: false
}
var url = 'my_url?id=1';
YAHOO.util.Connect.asyncRequest('GET', url, callback);
Please include YUI library also.
0 Comment(s)