Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

AJAX2 #760

Open
wants to merge 14 commits into from

2 participants

Stefan Andres Charsley Mislav Marohnić
Stefan Andres Charsley

Ajax2 uses XMLHttpRequest2 which supports FIFO events. Instead of
returning the XHR object directly, it returns a zepto wrapped object
with custom methods to add context-aware callbacks.

Allows use of post-execution callbacks similar to those of the jQuery AJAX object:
http://api.jquery.com/jQuery.ajax/#entry-examples

Documentation will come if merged into the main Zepto.JS

NOTE: jsonp has been deprecated and removed. AJAX2 is now focused around CORS for cross domain calls.

Stefan Andres Charsley charsleysa Created Ajax2 to use modern browser features
Ajax2 uses XMLHttpRequest2 which supports FIFO events. Instead of
returning the XHR object directly, it returns a zepto wrapped object
with custom methods to add context-aware callbacks.
59ed0cc
Mislav Marohnić
Collaborator

Admirable! Sorry this hasn't got much attention. Are you suggesting that we replace our current Ajax module with this, or…? Does this pass our old Ajax test suite? What is the browser support for Ajax2?

Stefan Andres Charsley

I propose to use this as a generation upgrade by deprecating the original ajax module and shifting focus to this module.

Ajax2 is supported in all browsers currently supported by Zepto.JS including IE10.

The old test suite is not completely compatible with this module so a new one will need to be drafted up.

Mislav Marohnić
Collaborator

Old test suite has a part of the suite making real web requests against a web server, so maybe those tests can work with Ajax2 without change?

Other tests create a mock XHR object so I guess those are useless for Ajax2.

Stefan Andres Charsley charsleysa Updated Ajax2 and first copy of test cases
Updated Ajax2 by adding responseType JSON shim until widespread browser
support.
Created first copy of the test cases, may be missing some tests and some
tests might fail.
cbc03a4
Stefan Andres Charsley

@mislav I managed to use the existing ajax test cases as a base.
I modified the mock XHR object to be compatible with XHR2 so I could keep most of the existing mock XHR based test cases.
There are some test cases missing but I haven't identified which ones yet.

charsleysa added some commits
Stefan Andres Charsley charsleysa FIX: Added Ajax2 to test list d7d33b5
Stefan Andres Charsley charsleysa Updated Ajax2 test cases
Updated the Ajax2 test cases which should pass now
a752a70
Stefan Andres Charsley charsleysa FIX: Ajax2 test case had resume error 4b981aa
Stefan Andres Charsley charsleysa FIX: Updated Ajax2 and Ajax2 test cases
Fixed Ajax2 parseArguments using wrong parameter names.
Fixed Ajax2 test cases not accounting for event data.
a578dc9
Stefan Andres Charsley charsleysa FIX: fixed variable names
Fixed variable names in both Ajax2 and Ajax2 test cases.
Renamed some instances of xhr to zeptoXhr in order to distinguish the
difference between Zepto XHR objects and Native XHR objects.
2a8f709
Stefan Andres Charsley charsleysa Extended Timeout c9778af
Stefan Andres Charsley charsleysa Extended resumeHandler timeout 994e4e9
Stefan Andres Charsley charsleysa Trying a different approach to the test c2ee10b
Stefan Andres Charsley charsleysa Testing without pause and with beforeSend 68d9f84
Stefan Andres Charsley charsleysa Extended testing timeout and removed setTimeout
Extended testing timeout and removed setTimeout.
I think setTimeout seems to fail when run from a XHR2 event.
949b29f
Stefan Andres Charsley charsleysa Removed setTimeout from the deferredResume 13187c3
Mislav Marohnić
Collaborator

Thanks for the hard work! I'll need some time to review this and test in various browsers. This is a big change and we can't be hasty about throwing the old ajax module out the window. Also, some tests fail on Travis; I don't know what's that about.

The key benefit why I want a better Ajax solution is to support the jQuery-style post-execution callbacks that you claim you have added here.

Stefan Andres Charsley

I have taken a look at the failed tests on Travis and I have no idea what is failing because I have recreated the tests on jsfiddle and they have worked as intended. The only bug I have found in the tests have been with the MockXHR but it fails way before it reaches that part. I'll be putting some more work into it whenever I have time.

Mislav Marohnić mislav was assigned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 16, 2013
  1. Stefan Andres Charsley

    Created Ajax2 to use modern browser features

    charsleysa authored
    Ajax2 uses XMLHttpRequest2 which supports FIFO events. Instead of
    returning the XHR object directly, it returns a zepto wrapped object
    with custom methods to add context-aware callbacks.
Commits on Aug 30, 2013
  1. Stefan Andres Charsley

    Updated Ajax2 and first copy of test cases

    charsleysa authored
    Updated Ajax2 by adding responseType JSON shim until widespread browser
    support.
    Created first copy of the test cases, may be missing some tests and some
    tests might fail.
Commits on Sep 2, 2013
  1. Stefan Andres Charsley
  2. Stefan Andres Charsley

    Updated Ajax2 test cases

    charsleysa authored
    Updated the Ajax2 test cases which should pass now
  3. Stefan Andres Charsley
  4. Stefan Andres Charsley

    FIX: Updated Ajax2 and Ajax2 test cases

    charsleysa authored
    Fixed Ajax2 parseArguments using wrong parameter names.
    Fixed Ajax2 test cases not accounting for event data.
  5. Stefan Andres Charsley

    FIX: fixed variable names

    charsleysa authored
    Fixed variable names in both Ajax2 and Ajax2 test cases.
    Renamed some instances of xhr to zeptoXhr in order to distinguish the
    difference between Zepto XHR objects and Native XHR objects.
  6. Stefan Andres Charsley

    Extended Timeout

    charsleysa authored
  7. Stefan Andres Charsley
  8. Stefan Andres Charsley
  9. Stefan Andres Charsley
  10. Stefan Andres Charsley

    Extended testing timeout and removed setTimeout

    charsleysa authored
    Extended testing timeout and removed setTimeout.
    I think setTimeout seems to fail when run from a XHR2 event.
  11. Stefan Andres Charsley
Commits on Sep 5, 2013
  1. Stefan Andres Charsley
Something went wrong with that request. Please try again.