jQuery + AjaxCFC Tutorial Part 3: Debugging

If there's one thing that's for certain it's that Ajax is very cool stuff, and everyone it seems is using it. It allows us as developers to provide for that slick desktop app sort of feel inside of a browser.

On the other hand: debugging ajax calls can be a serious pain in the butt! There are tools out there to help us though: Fiddler, FireBug, GreaseMonkey, Venkmen, etc. and those are fine, but Rob Gonda has provided us ColdFusion programmers with even more functionality when it comes to debugging our XMLHttpRequest calls.

[More]

Comming Soon!

I've been stupid busy at work recently writing code for two client's both of which have deadlines that need to be met, changes to be made, bugs that need fixing... you probably know the drill.

On top of that I've recently been diagnosed with high blood pressure, high cholesterol, and diabetes! Sucks to be me, huh? Anyway, the upshot is that I've really not had a lot of time to do all the things that I want to do for the CFJS project. I'm also writing a tutorial about using Rob Gonda's AjaxCFC with jQuery that I promised a few folks I'd get published soon.

So today I received an email from Trent Richardson not only offering to help with the CFJS project, but he put his money where his mouth was... or his code where his mouth was... or something, and wrote the IsValid() function that he was suggesting be added to the library! How cool is that!

This is my first open source project, so it's super cool to me that a) people are using it and b) that someone is willing to help the cause! I'm stoked. Thanks Trent!

Anyway (@Neil), I'm going to try to finish the tutorial and my goal is to get it up tonight. Things have finally calmed down a little with my clients, so hopefully I'll be able to get some work done on these projects (as well as fit in a movie or two ;o).

BTW: I just saw the Transformers movie tonight. It was awesome! And (as the folks in Hollywood are apt to do) they totally left it open for an other movie.

AjaxCFC for jQuery Updated with New Version of CFJSON

I Found out today that Rob Gonda's AjaxCFC has just received a new update where CFJSON is concerned. Turns out that version cfjson v1.6b was buggy so he's moved it to v1.7.

Rob is strongly suggesting that we get the update.

One thing's for certain, I'm getting it. You should too. ;o)

Here's a link to the original post on Rob's Blog.

Cheers, everyone!

AjaxCFC, a short story about a lesson learned

Okay, I admit it. It was entirely my fault.

A couple of weeks ago I was writing some code for a client of mine, making the app all Web 2.0-y-ish. I'm using AjaxCFC for jQuery and it keeps telling me that a critical error has occurred and that I can click OK to see what's the matter.

So, I click. And all I see is my data in the resulting popup; Not an error, but the actual data that I was expecting back! Um... is this a bug in AjaxCFC? I'm not sure, so I check and re-check my code. I try several things, but I'm just grasping at straws. So, I ask Rob Gonda what the heck I'm doin' wrong.

Well, he helped me as best he could, but in the end it wasn't AjaxCFC at all! Finally I figure out what the problem is: in the success parameter of the AjaxCFC call, I was immediately trying to dump the resulting data using $.dump(data);. Well, there's nothing wrong with that... unless you've forgotten to include the plug-in that makes the $.dump() function work.

oops... color me embarrassed.

So, today it happens again! I check and re-check my code again, and whereas last time I was using a $.dump(); this time I was just using a plain ol' alert();

Well, long story short (what's that you say? too late?) it turns out that the line of code I'd put in was:

$.AjaxCFC({
    url: "myCFC",
    method: "myMethod",
    data: {},
    serialization: "json",
    success: function(data){
        alert(done); /* hmm... what's wrong with this line?*/
    }
});

instead of:

$.AjaxCFC({
    url: "myCFC",
    method: "myMethod",
    data: {},
    serialization: "json",
    success: function(data){
        alert("done"); /* That's right it was supposed to be a string... d'oh!*/
    }
});

So, the moral of the story is: If AjaxCFC tells you there's an error, but it only shows you the data you expected... you've probably made some other mistake elsewhere in your JavaScript. Most likely in the success parameter of the ajax call. So triple-check your code. It could just be a boneheaded mistake. :o)

Thanks for all your patience Rob. And thanks for a wonderful plug-in!

Cheers

BlogCFC was created by Raymond Camden. This blog is running version 5.9.4.001. Contact Blog Owner