Coding RESTful API Call using Jquery ~ Web CodeHelpers

Coding RESTful API Call using Jquery

In this tutorial we are going to discuss about doing a RESTful API call using Jquery with example

Using Jquery Ajax we can do the RESTful API call, We can render the data JSON / XML in the webpage / webapplication

jQuery Ajax function basically performs an asynchronous HTTP request with parameters

  • type is the request method. Possible values can be GETPOSTDELETEPUT, etc. Here we are making a "GET" request.
  • url represents a resource on the web. In our case, we are providing service URL.
  • datatype specifies the type of data returned from server, i.e., xml, text, html, script, json, jsonp.
  • success is the callback function that will be invoked when request gets completed.
  • error is also a callback function that will be called in case of request failure.





The above code will the show the demo how we call the RESTapi using jquery

Success Call back will hold the Success data of response

Error Call back will hold the Error data




0 comments :

Post a Comment

Subscribe updates via Email