Skip to content
Browse files

Adding JSONP support for Cross-Domain support during refreshes

Changing the refresh call to use jQuery, which has built-in support for
JSONP, which enables cross-domain requests.  Graphite already supports
this style of request, so it's a little simpler to do this than some of
the alternatives for cross-domain support
  • Loading branch information...
1 parent e25b93d commit 6aa6fd2140e3124798f45d5f732b8a776ee5b87f Dan Cartoon committed Apr 8, 2012
Showing with 12 additions and 3 deletions.
  1. +11 −2 app/js/graphene.coffee
  2. +1 −1 build/index.js
View
13 app/js/graphene.coffee
@@ -59,10 +59,19 @@ class Graphene.GraphiteModel extends Backbone.Model
clearInterval(@t_index)
refresh: ()=>
- d3.json @get('source'),
- (js) =>
+ url = @get('source')
+ #jQuery expects to see 'jsonp=?' in the url in order to perform JSONP-style requests
+ if -1 == url.indexOf('&jsonp=?')
+ url = url + '&jsonp=?'
+
+ options =
+ url: url
+ dataType: 'json'
+ jsonp: 'jsonp'
+ success: (js) =>
console.log("got data.")
@process_data(js)
+ $.ajax options
process_data: ()=>
return null
View
2 build/index.js
1 addition, 1 deletion not shown because the diff is too large. Please use a local Git client to view these changes.

0 comments on commit 6aa6fd2

Please sign in to comment.
Something went wrong with that request. Please try again.