Loading ...
Sorry, an error occurred while loading the content.

[ANN] Debugging and TDDing Ajax with jQuery just got easier

Expand Messages
  • gutzofter
    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. So I wrote
    Message 1 of 1 , Aug 6, 2010
    • 0 Attachment
      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.

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

      The source is here: [http://github.com/gutzofter/ajaxMonitor%5d

      The unit tests for the source can be run here: [http://gutzofter.herobo.com/ajaxMonitor/ajaxMonitor-1.0.0/tests/unit/tests.ajax.monitor.php%5d

      The unit tests validating with jQuery 1.4.2 Ajax tests with the plug in can be run here: [http://gutzofter.herobo.com/ajaxMonitor/ajaxMonitor-1.0.0/tests/unit/validation/%5d[2]

      The plug-in is still in beta!

      Cause there are 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.

      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.




      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

      [http://dev.jquery.com/ticket/5383%5d.


      [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 here: [http://stackoverflow.com/questions/3419782/cannot-pass-all-jquery-1-4-2-ajax-unit-tests-with-my-plug-in%5d


      Thanks,


      Joe Gutierrez

      gutzofter@...
    Your message has been successfully submitted and would be delivered to recipients shortly.