jupiterjs / jquerymx

jQuery MVC Extensions. jQuery extensions that makes all the annoying stuff easier.
http://javascriptmvc.com
553 stars 374 forks source link

Fixture does not return correct datatype when error is thrown #129

Closed mokkabonna closed 9 years ago

mokkabonna commented 12 years ago

jQuery ajaxTransport does not accept datatype json when you return an error, leaving responseText empty.

$.fixture('POST /api/links', function() {
    if(!data.Text)  return [403, "Forbidden", { text:  'The field Title is required.'} , {}];
            //etc
});

Fixture will modify this and send the following to ajaxTransport

403, 'Forbidden', {json:{text:'The field Title is required. ' }}, {}

While it should be

403, 'Forbidden', {text:'The field Title is required. ' }, {}

That way when you do

myrequest.fail(function(jqXHR){
    console.log(jqXHR.responseText ) //Not undefined
});