Closed ivospinheiro closed 6 years ago
When an error is returned from and xhr.dataType is of type 'json', can-ajax is always parsing the responseText to JSON even if it hasn't a valid JSON format.
Here is an example that demonstrates the different behavior of can-ajax comparing with jQuery ajax: https://codepen.io/ivospinheiro/pen/mjQPVN?editors=1011#code-area
The parse of "xhr.responseText" to JSON should be within a try catch block on line: https://github.com/canjs/can-ajax/blob/a36ffc126fb42a0940c6f1208cd47a31b3124167/can-ajax.js#L119
When an error is returned from and xhr.dataType is of type 'json', can-ajax is always parsing the responseText to JSON even if it hasn't a valid JSON format.
Here is an example that demonstrates the different behavior of can-ajax comparing with jQuery ajax: https://codepen.io/ivospinheiro/pen/mjQPVN?editors=1011#code-area
The parse of "xhr.responseText" to JSON should be within a try catch block on line: https://github.com/canjs/can-ajax/blob/a36ffc126fb42a0940c6f1208cd47a31b3124167/can-ajax.js#L119