Created
February 27, 2016 17:45
-
-
Save deepakkj/6861a2502e17282d7566 to your computer and use it in GitHub Desktop.
Revisions
-
deepakkj created this gist
Feb 27, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ <!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-1.11.3.js"></script> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>Deepak Kumar Jain</title> </head> <body> <h1>Updating a item in JSON data using 'PUT' method</h1> <h4> - Using Jquery and REST API</h4> <h2>Updating existing Friend's Detail</h2> <small>Thanks to http://rest.learncode.academy/ for providing the RESTful API </small> <script> //using AJAX to add a update a collection/item to the JSON data from the given URL and call respective functions on success/error. //URL used is only for learning/educational purposes. Cannot be used for production. $.ajax({ type: "PUT", data: {"name": "Mohan", "age": "20"}, //here pass in respective "id" number in the URL to update an item url: "rest.learncode.academy/api/deepak/friends/56d167d028e38101004a7e2d", success: function(data){ console.log("Data updated/modified successfully"); }, error: function(data){ console.log("Error in updating/modifing data"); } }); </script> </body> </html>