Jump to content

PARSING JSON feed !!!!


jijodasgupta

Recommended Posts

hey guys,ive a code to parse json feed off twitter dependin on the input(say a word) the user provides....

<script type="text/javascript"> 
    $(document).ready(function(){
        $('form#search').bind("submit", function(e){
            e.preventDefault();
            $('#content').html('');
            
            var query = urlencode($('input[name="searchTerm"]').val()); //what to search for
            var rpp = 20; //number of tweets to retrieve out
            
            $.getJSON('http://search.twitter.com/search.json?callback=?&q='+query+'&rpp='+rpp, function(data){
                 $.each(data.results, function(i, item){
                    console.log(item);
                     var newDiv = '<p><a href="http://www.twitter.com/'+item.from_user+'">'+item.from_user+'</a> - '+item.text+'</p>';
                     $('#content').append(newDiv);
                 });
             });
        })
        
        function urlencode(str) {
            return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
        }        
    })
    </script> 

...now i wanna do smthin different...i wanna highlight tht particular word i the json text before echo-ing it....how do i do tht using javascript n css???

Link to comment
https://forums.phpfreaks.com/topic/146335-parsing-json-feed/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.