Monday, 24 November 2014

Simple jQuery Ajax Call

1.Using done Method.

$.ajax({
  type: "POST",
  url: "server url",
  data: { name: "bujjiBabu", location: "hyderabad" }
}).done(function( msg ) {
    alert( "Data Saved: " + msg );
  }).fail(function(msg){
    alert( "Data Saved: " + msg );
});

2.Using success Method.

$.ajax({
type: "POST",
  url: url,
  data: { name: "bujjiBabu", location: "hyderabad" },
  datatype:datatype,
  success: function(){
    alert('success');
  },
  error: function(){
   alert('error');
  }
});

No comments:

Post a Comment