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 678515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:09:29+00:00 2026-05-14T01:09:29+00:00

I make a call to the twitter API. 100 posts are retreived + a

  • 0

I make a call to the twitter API. 100 posts are retreived + a properties that tells me what the next page to call is. So I wait 5 sec. and call that next page, but the JSon results in the callback function is always null the second time… I think it’s probably a JQuery problem…

Here’s the code to test it if you want :

<html>
<head>
<script type="text/javascript" src="./jquery-1.4.2.min.js"></script>
<script>
function test() {
    var rqUrl = "http://search.twitter.com/search.json?q=%23apple+OR+%23ipad&rpp=100&callback=?"
    callTwitterSearchApi(rqUrl);
}

function callTwitterSearchApi(tiwtterRequestUrl) {
    debug("request to twitter : " + tiwtterRequestUrl);

    // *** FIRST CALL WORKS GREAT... ***
    $.getJSON(tiwtterRequestUrl, callTwitterSearchApi_callback);
}

function callTwitterSearchApi_callback(jsonPostsResults) {
    debug("callback");

    if (jsonPostsResults == null) {
    debug("Why is jsonPostsResults null? If I copy paste the request inside a browser, I get something =(");
    return; 
    }

    if (jsonPostsResults.error != undefined && jsonPostsResults.error != "") {
        debug("twitter api error");
    }
    var posts = new Array();
    $(jsonPostsResults.results).each(function() {       
        posts.push(this);
    }); 

    debug("Number of posts : " + posts.length);

    if (jsonPostsResults.next_page != undefined && jsonPostsResults.next_page.trim() != "") {        
        debug("calling next request in 5 sec..."); 
            // *** WHEN COMMING BACK FROM THAT LINE, JSON RESULTS == NULL?! ****
        setTimeout("callTwitterSearchApi(\"http://search.twitter.com/search.json" + jsonPostsResults.next_page + "\")", 5000); 
    }

}

function debug(message) {
    document.getElementById('debug').innerHTML = message + "\n" + document.getElementById('debug').innerHTML;
}
</script>
</head>
<body>
<input type="button" onclick="test();" value="test" /><br />
<textarea id="debug" cols="80" rows="20"></textarea>
</body>
</html>

So, at line 20, at the second callback (back from the setTimeout), the parameter “jsonPostsResults” is always returned as null… I have no idea why. If I copy paste that 2nd request in a browser, it returns 100 results. Anybody had a problem like that with the Ajax/JQuery functions when calling it with a setTimeout?

  • 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-14T01:09:30+00:00Added an answer on May 14, 2026 at 1:09 am

    It’s because you haven’t specify ‘&callback=?’ at second request

    Fix:
    setTimeout(“callTwitterSearchApi(\”http://search.twitter.com/search.json” + jsonPostsResults.next_page + “&callback=?\”)”, 5000);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.