This is my first blog post when I just started working on the Web Development.
I had to call a Web Service in an HTML page to display the data on the screen.
I googled and found multiple Ajax call examples but didn't find a simpler one to get started with.
So, I created one myself so that I can refer it as and when needed.
Check it out if that helps you as well:
$.ajax({
type: "POST",
url: "test.htm",
data: "param1=value1¶m2=value2",
success: function() {
// code to execute after the ajax call succeeds
},
error: function() {
// code to execute after the ajax call fails
}
});
Here,
type:- is the request type i.e Get/Post/Put/Delete
url:- is the url of the web service or the request
data:- is used to send the parameters along with the request
success:- is the callback function which triggers after the request returns successfully
error:- is the callback function which triggers after the request fails
Comments
Post a Comment