How to use this json and show it in browser?
I frequently use this twitter api website to search. It provides its own api. Now I want to try it but do not know how to do it. My idea is:
- Put a search box in html and in
onclick
event it will retrieve json 开发者_如何转开发 - Parse that json and count the length of each tweet (only length of tweet text, not userid)
- Display each tweet userid, date, link, text (all tweet data) in browser
- Length of tweet text is appending to (3) for each tweet
I am new in javascript and json. Will you let me know how to retrieve json and do above?
First, it would help to review the fundamentals of JSON requests. Once you do that, feel free to brush up on jQuery and use jQuery.getJSON() to retrieve the JSON you want from a given URL. Here's some pseudo code:
$.ajax({
url: 'http://tweetscan.com/json.php',
dataType: 'json',
data: { 's' : 'some search phrase' },
success: function (response) {
// Do something with JSON response.
}
});
精彩评论