Using ajax with jQuery is simple.
I see multiple methods on web. some call like
$.ajax({
type: "POST|GET",
dataType: "json|xml|....",
url: "index.php|
data: param{i guess name value pairs but i am not sure},
success: function(data){
if(data.status==0){
// take action... In general programming practice,
// trueSuccess will be a function which will be called with data as argument.
// In this case, trueSuccess is an event which will be triggered ....
// This event is having some data as argument...
$("#"+listener).trigger('trueSuccess',[data]);
}else{
$("#"+listener).trigger('trueError',[data]);
}
},
error: function(){
data='An Unexpected error has occured. Please try again later.';
$("#"+listener).trigger('unexpectedError',[data]);
}
})
Ajax another way:
$.get("giveMeSomething.php", { number1: number1, number2: number2 },
function(data){
alert("Data Loaded: " + data);
});
No comments:
Post a Comment