Note that there are some explanatory texts on larger screens.

plurals
  1. POMerging JSON api Response using Javascript
    primarykey
    data
    text
    <p>I am trying get paged json responses from Topsy (http://code.google.com/p/otterapi/) and am having problems merging the objects. I want to do this in browser as the api rate limit is per ip/user and to low to do things server side.</p> <p>Here is my code. Is there a better way? Of course there is because this doesn't work. I guess I want to get this working, but also to understand if there is a safer, and/or more efficient way.</p> <p>The error message I get is ...</p> <p>TypeError: Result of expression 'window.holdtweetslist.prototype' [undefined] is not an object.</p> <p>Thanks in advance.</p> <p>Cheers Stephen</p> <pre><code> $("#gettweets").live('click', function(event){ event.preventDefault(); getTweets('stephenbaugh'); }); function getTweets(name) { var MAX_TWEETS = 500; var TWEETSPERPAGE = 50; var BASE = 'http://otter.topsy.com/search.json?type=tweet&amp;perpage=' + TWEETSPERPAGE + '&amp;window=a&amp;nohidden=0&amp;q=@' + name + '&amp;page=1'; var currentpage = 1; alert(BASE); $.ajax({ dataType: "json", url: BASE, success: function(data) { window.responcesreceived = 1; var response=data.response; alert(response.total); window.totalweets = response.total; window.pagestoget = Math.ceil(window.totalweets/window.TWEETSPERPAGE); window.holdtweetslist = response.list; window.holdtweetslist.prototype.Merge = (function (ob) {var o = this;var i = 0;for (var z in ob) {if (ob.hasOwnProperty(z)) {o[z] = ob[z];}}return o;}); // alert(data); ;; gotTweets(data); var loopcounter = 1; do { currentpage = currentpage + 1; pausecomp(1500); var BASE = 'http://otter.topsy.com/search.json?type=tweet&amp;perpage=' + TWEETSPERPAGE + '&amp;window=a&amp;nohidden=0&amp;q=@' + name + '&amp;page=' + currentpage; alert(BASE); $.ajax({dataType: "json", url: BASE, success: gotTweets(data)}); } while (currentpage&lt;pagestoget); } }); }; function gotTweets(data) { window.responcesreceived = window.responcesreceived + 1; var response = data.response; alert(response.total); window.holdtweetslist.Merge(response.list); window.tweetsfound = window.tweetsfound + response.total; if (window.responcesreceived == window.pagestoget) { // sendforprocessingsendtweetlist(); alert(window.tweetsfound); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload