Permalink
Browse files

Fix client on Firefox 34.0 beta

Our ajax function was passing params as object to xhr.send function.
For some reason this breaks on Firefox 34.0 beta. Sending stringified
version of params works correctly.
  • Loading branch information...
1 parent 9553849 commit 9057650646282644ecd49b6606f3c891b96e9fd4 @drogus drogus committed Nov 13, 2014
Showing with 8 additions and 1 deletion.
  1. +8 −1 assets/scripts/lib/travis/ajax.coffee
View
9 assets/scripts/lib/travis/ajax.coffee
@@ -27,6 +27,9 @@ Travis.ajax = Em.Object.create
!publicEndpoint || privateEndpoint
ajax: (url, method, options) ->
+ # TODO: we have our own ajax implementation, because jQuery didn't
+ # properly worked with headers on firefox, it would be nice to check
+ # if this is still a problem and if we can remove this
method = method || "GET"
method = method.toUpperCase()
@@ -135,6 +138,10 @@ Travis.ajax = Em.Object.create
reject(xhr)
options.error.call(data, xhr.status, xhr)
- xhr.send(options.data)
+ data = options.data
+ if typeof(options.data) == "object" && (Ember.isNone(options.contentType) || options.contentType.match /application\/json/)
+ data = JSON.stringify(data)
+
+ xhr.send(data)
return promise

2 comments on commit 9057650

@hallvors

Alternative fix:

# HTTP doesn't support sending data with GET or HEAD
if(/^(GET|HEAD)$/.test(method)) data = null;
xhr.send(data)
@hallvors

(The fix you've implemented makes sense too - if this code is ever called with a POST you'd now send JSON instead of the string "[object Object]" :))

Please sign in to comment.