Archive for the ‘Ajax’ Category

Announcing: Debugging and TDDing Ajax with jQuery just gotĀ easier with ajaxMonitor

August 6, 2010

I am freakin’ excited!

I got tired of switching between tabs and firebug when trying to figure out what the hell was going on with my ajax requests.

The worst is when I tried finding anything about my requests in Internet Explorer. Forget it!

So I wrote a jQuery Plug-in. You attach it to your page and it will monitor all your Ajax requests [1].

One Click —-> Get the plug-in ajaxMonitor <—- One Click

The running unit tests for the source.

The running unit tests validating with jQuery 1.4.2 Ajax tests with the plug in. [2]

Two feature that are becoming a must have for this plug in

1> Mocking Ajax request by specifying your Ajax settings like this: { /*other settings*/ mock: true }

2> What I’m going to call single-shot.

  • Fire an AJAX request once
  • For all repeat requests will beĀ  mocked with the response data.

Presently the way I TDD a client, is I retrieve content using the normal Ajax call to get the presentation HTML.

Then I make another Ajax call in my normal code and store it into a string. At the start of each test I load this string into my: $(‘#contentContainer’).html(myPreloadedPresentationHTML);

Then remove it. So for all the unit tests I make a total of TWO Ajax calls. That’s one too many calls (latency can be up to 1~2 seconds OUCH!).

Since the monitor already controls the success callback of the original Ajax request why not replace it with my own.

First Ajax request success supplies the response data.
Hang onto it.
Any other calls to this request will get the stored response data.

I would welcome any comments.

Good or Bad!

…even requests.

Please help push against this software. I think it is a great tool and could be better with your help.

[1] Because jQuery 1.4.2 executes the complete callback twice during the request. If you want you can include my modified jQuery 1.4.2 library that fixes this use it. See here for bug tick #5383 .

[2] Two failing tests dealing with preserving the context. It is caused by XPC Cross Origin Wrapper. If anybody has a fix, post on stackoverflow.com.

Thanks from the ajaxMonitor Team.