How to get a JSON object from a RESTful api and parse it?

Now one of my friends designed a set of RESTful APIs. Some of them are 'GET' method and return JSON format data.

And I have to write a html page with some javascript code to get data from his API and parse the data.

When I enter a text and click a button, it will send a GET request to my friend's API server. How to send this request and get this json data from this api and store it in a javascript variable?.

And the format of this json data is like that:

key1 : "value1",
key2 : "value2",
key3 : "value3",
key4 : "value4"
key1 : "value1",
key2 : "value2",
key3 : "value3",
key4 : "value4"

How to display it on html page in a table with the first row is the name of all keys? And the other rows is all the values?

And can set one value like value4 as a hyperlink where I can click? When I click it, it will create a new page and get something new from the API server?


This is somehow a very long to answer question. I will give you some directions.

take a look at jQuery.ajax() method if you are using jQuery. If not, I recommend you do that. site is:

That will help you make the request and get the data back into a Javascript Object.

Then you can update the DOM which also jQuery is very useful to update or create a table with the data.

Either way, I recommend to check out some MVVM libraries to ease some of the work like Knockout.js or Angular.js

Depending on your skills this might be a little bit 'hard' to get to know, so you can learn jQuery first and manipulate the DOM using it so you can achieve the result you want.

Need Your Help

Local Regex Match Variable Not Updated

javascript regex node.js

I am looping through an array of objects and mapping them to my own custom objects. I am extracting data via regular expressions. My first run through the loop works fine, but in subsequent itera...

Statistics on Location Settings vs. Power Consumption

iphone ios gps cllocationmanager power-management

Is there any data on how GPS power consumption changes with different CLLocationManager settings, such as desired accuracy and distance filter? How it changes between different iPhone models? How it

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.