#44 Debugging RJS
RJS and AJAX can be difficult to debug. Many times you don't get any error message in the browser. Learn different techniques for solving these tricky problems in this episode.
- Download:
- mp4Full Size H.264 Video (18.8 MB)
- m4vSmaller H.264 Video (10.9 MB)
- webmFull Size VP8 Video (22.8 MB)
- ogvFull Size Theora Video (27.3 MB)
Hey, Ryan - a common situation I come across is uploading a file via AJAX, with a progress bar (like the way Basecamp implements it for their file uploads). This could be a good idea for a future screencast.
As usual, great screencast! :)
Now, for what matters, the first problem is easy to debug via firebug, too. You just go to the console (Ctr+Shift+L, by the way, realy handy time saver), click on the request and watch the response, which should be the stack trace.
As for the last error, as rails wraps the whole thing in a try catch block, then it's a bit of a hassle, but if you really can't find the error, you can just go to the response in firebug, copy it and execute it on the console, finding the guilty statement really easy :)
I mean, really, firebug is the solution for all (ok, just most) problems out there. The one that aren't solved by Firebug are solved by "Use Rails" :P
Oh, and by the way, on a slightly unrelated, another great tool to incorporate into Firefox is Chris Pederick's (did I get that right?) Web Developer Toolbar. It mostly helps on some stuff that firebug hasn't come into attention yet, such as site accessibility. Those are my two "best extensions", by far.
(If you do too much front end stuff, you ought to yourself to stop using Safari while developing. I mean, I also rather use Safari as it's faster, but for development the extensions for firefox make it really great, particularly this too I recommended)
Oh, I forgot, there's a nice Firebug "power user demo" by Joe Hewitt (the author) @ http://video.yahoo.com/video/play?vid=cccd4aa02a3993ab06e56af731346f78.1755924&fr=
Thanks for the great tips Nicolás!
Loving your screencasts. Most topics I think I know already, but each episode I learn some little gems, like TextMate and Rails method shortcuts, that make me that much more productive.
I eagerly await the next episode.
Hey - I love the screencasts - especially the new ipod format!
I'm afraid that this one seems to have a corrupted mp4 files. I can't run them on either iTunes for windows or my iPod. This mp4 is coorrupted about 2:19 into it...
Keep up the awesome work!
@Geoff, I recompressed it and reuploaded it. Hopefully it will work now. :)
Ryan - thank you for these screencasts. They're extremely helpful. I have one question regarding this topic. I'm trying to update a DOM, but the DOM is in javascript so I can't see it in the browser view-source to see if I have the correct id. I can see the javascript that's sent to the browser with firebug, but it's quite indecipherable (to me). Is there any way to view the javascript as html?
What's funny, is when the javascript broke, it didn't add the HTML to the bottom. However, the Ruby part worked, so the comment was created. Then, after the bug in the rjs was found, and you said it was working, the page only showed two comments but the comment count showed three, because it was pulling from the db. Then, when you loaded the page in Firefox (i.e. the page was refreshed) everything was working fine. Anyway, just a little nuance, and possibly a topic of client side and server side scripting/writing to the db.
just learn how to code like pro in pure Javascript then you would not need buggy heavy slow frameworks.... and you control you own destiny and you can enjoy the power of knowing