Don't error out if response is not valid JSON

This commit is contained in:
Piotr Sarnacki 2013-05-15 16:50:47 +02:00
parent 1fa040d9a3
commit 895b52d7c4

View File

@ -96,7 +96,10 @@ Travis.ajax = Em.Object.create
if xhr.readyState == 4 if xhr.readyState == 4
contentType = xhr.getResponseHeader('Content-Type') contentType = xhr.getResponseHeader('Content-Type')
data = if contentType && contentType.match /application\/json/ data = if contentType && contentType.match /application\/json/
jQuery.parseJSON(xhr.responseText) try
jQuery.parseJSON(xhr.responseText)
catch e
console.log('error while parsing a response', method, options.url, xhr.responseText)
else else
xhr.responseText xhr.responseText