mythz/jquip — pull request #15 by solarissmoke (2011-12-28 07:55:42+00:00)
Title: Fix some Ajax issues

Hello! I've been using jQuip.ajax quite a bit and have come into some issues:

- the `dataType` argument should specify what data type the *response* is expected to have. The type of the request should be set by `contentType` (which was defined in the defaults but not used anywhere). Currently the code uses `dataType` to modify the type of data *sent* (i.e., stringifies it if `dataType` is set to `json`), meaning that if you are expecting a `json` response you are forced to send a `json` request - this should not be the case. I've tried to separate the two by making use of `contentType`.

Note however that the stringify code has been removed altogether - I was thinking on the basis that if the user sets a custom content type then they should be supplying the data in that type, otherwise we assume is is `x-www-form-urlencoded`. If this is going to break backward compatibility then it may need to be reworked.

- the call to formData() for GET requests fails because formData doesn't exist within the current scope. It needed to be wrapped in `$[]`.

- The default dataType is set to `application/json`, which I don't think should be the case. I think we should be using the response headers to work out the data type unless it has been set manually.