Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1085201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:39:35+00:00 2026-05-16T22:39:35+00:00

I built a very simple Twitter Instant Search for fun, using jQuery and PHP.

  • 0

I built a very simple Twitter Instant Search for fun, using jQuery and PHP. I bind an event to keyup on the search form, and make a quick AJAX call to a PHP page that curls Twitter Search JSON.

<script>
$(function(){
 $('#search').bind('keyup', function(){
  var v = $('#search').val();
  console.log(v);
  $.get('get.php',{q: v, a:''}, function(data){
   obj = {};
   window.tw = '';
    obj = eval('('+ data +')');
  if(typeof obj.results.length !== undefined){
    for (var i=0; i < obj.results.length; i++) {
     tw += '<div class="tweet"><h2><a target="_blank" href="http://twitter.com/'+obj.results[i].from_user+'">@'  + obj.results[i].from_user + '</a></h2> <span>' + obj.results[i].text + '</span><' + '/div>';
    };
    }
   });
 $('#container').html(window.tw);  
 });

});
</script> 

Even though the console.log value returned is right, it still falls behind 1-2 characters, in terms of the results it displays. Why? How can I fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:39:36+00:00Added an answer on May 16, 2026 at 10:39 pm
    $('#container').html(window.tw); 
    

    This should be inside the callback given to $.get()

    $(function(){
        $('#search').bind('keyup', function(){
            var v = $('#search').val();
            console.log(v);
            $.get('get.php',{q: v, a:''}, function(data){
                obj = {};
                window.tw = '';
                            obj = eval('('+ data +')');
                            if(typeof obj.results.length !== undefined){
                    for (var i=0; i < obj.results.length; i++) {
                        tw += '<div class="tweet"><h2><a target="_blank" href="http://twitter.com/'+obj.results[i].from_user+'">@'  + obj.results[i].from_user + '</a></h2> <span>' + obj.results[i].text + '</span><' + '/div>';
                    };
                }
                $('#container').html(window.tw);    
            });
    
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I built a very simple app using a PHP form with a bit of
I've built a very simple website using PHP Includes to display the footer and
I have a very simple chat system I've built using PHP and MySQL (this
I have built a very simple blog application using Ruby on Rails. New to
I have built a variety of little scripts using Ruby's very simple Queue class,
I have built a very simple CakePHP website using the Auth component and have
i built several sites with very simple code of php and so far so
I've built a custom page.php template. Very simple, essentially: <?php get_header(); ?> <?php get_sidebar();
I don't believe this: Just built a very simple form with one combobox, when
I've built a very simple table that displays 4 columns and 4 rows. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.