Thanks Matt, that really helped explain things. I tried to use a straight $.ajax(...).ajaxError to catch the error.
It didn't work. My solution was to toggle a loader gif before the transaction, set the timeout in $.ajax to 4000ms, and made a setTimeout at 4100ms to a function that checked if the loader gif was still shown. If so, it reported a problem to the user. This is obviously a very, very ugly hack. But it worked. :D Look for an update soon about what this little project is all about at my twitter stream: http://twitter.com/tipjoy The final mini app that we've made will be a pretty good example of how to very quickly extract info from the twitter API using jquery. Ivan http://tipjoy.com On Jan 7, 11:07 am, Matt Sanford <[email protected]> wrote: > Hi Ivan, > > The jQuery getJSON replaces the trailing "?" with a function name > like jsonp4728701093601231 [1]. To test you need to use something more > like: > > $ curl 'http://twitter.com/users/show/someBadUsername.json?callback=foo' > foo({"request":"\/users\/show\/someBadUsername.json? > callback=foo","error":"Not found"}) > > It looks like the Twitter API is working correctly. One thing to > note is that the Twitter API is returning HTTP 404. I am pretty sure > the jQuery getJSON method is only calling your function on success > (HTTP 200). I'm not totally sure but the jQuery ajaxError event > handler may help do what you need. > > Thanks; > — Matt Sanford / @mzsanford > > [1] - "jsonp" + currentTimeMillis > > On Jan 7, 2009, at 07:48 AM, Ivan wrote: > > > > > Hi, > > > I'm cofounder of Tipjoy - we just made payment on twitter. Check it > > out:http://tipjoy.com/twitter > > > We have a fun project related to this that I'm working on right now. > > > I'm using jquery to parse the twitter account info from the API. > > Disclaimer: I'm learning javascript JIT. > > > There is either a bug in my javascript, or the return from the twitter > > API is wrong. > > > Here is some simplified code: > > > $(document).ready(function(){ > > var url = "http://twitter.com/users/show/" + [the username] + > > ".json?callback=?"; > > $.getJSON(url, > > function(data){ > > if( data.error ){ > > alert("username doesn't exist") > > } > > else{ > > alert("that username exists") > > } > > } > > ); > > }); > > > This code uses jquery's getJSON to grab the account info for a given > > username. > > > The return for a correct username is: > > ({...}); > > > That wrapping is to pass it to the callback unnamed function. > > > But this code doesn't work for a username that doesn't exist. The > > function doesn't even get called, and the alert doesn't show up. > > > Putting this is a browser > >http://twitter.com/users/show/someBadUsername.json?callback=? > > > Returns: > > {"request":"\/users\/show\/someBadUsername.json? > > callback=?","error":"Not found"} > > > Should that be wrapped in ({...}); ? Is that a bug on twitter's side? > > > Or is there something I'm doing wrong in jquery? > > > I looked at the code for this project, and it looks like they are > > using jquery to access summize in the same way I'm grabbing from the > > twitter api. > >http://tweet.seaofclouds.com/ > >http://github.com/seaofclouds/tweet/tree/master/javascripts/jquery.tw... > > > Any help would be greatly appreciated. > > > Thanks, > > Ivan > >http://tipjoy.com
