OK, how do I get data for a browser plugin?

I've been trying to create a browser plugin that I can use to display power usage (javascript, so I can get cool gauges and such).  I have used this URL and can get data to display on the screen: "http://emoncms.org/feed/value.json?id=8387&apikey=secretnumber" . But when I put it into one of those silly looking ajax calls, I get the (famous)  "is not allowed by Access-Control-Allow-Origin" errors.

I tried datatype 'jsonp', nothing.  Straight 'text', still nothing.

How the heck do I do this?

PS, and also, how do I subscribe to posts?  I can't seem to find that either.  (not having a good day)

ukmoose's picture

Re: OK, how do I get data for a browser plugin?

As you probably already guessed using javascript you can't download data other from a different domain via json.

There's a good write up on http://en.wikipedia.org/wiki/JSONP.

The trouble with JSONP is that there are still security issues with it.  

As it is a different format, the server also needs to support it.

So the one way to get around this is to host the script on the same domain as the data, which you can achieve by hosting your own emoncms database. 

 

 

How to subscribe?  Click on subscribe underneath you post ( left hand side)

 

 

 

draythomp's picture

Re: OK, how do I get data for a browser plugin?

As I understand it, you are correct.  Except, I do this every day with Cosm using the 'json' parameter and my read only access key.  A friend of mine does something similar with nimbits.  So, the other services like this one must have the server configured to deliver json data.  There's a good article on this at http://www.cypressnorth.com/blog/programming/cross-domain-ajax-request-w... .  I guess I misunderstand something; isn't idea of a data storage service like emoncms to serve data back when needed?  Especially when this can lead to lots of plugins, charts with huge capabilities, and really cool bells and whistles? 

re subscribe, Yes, I finally found it.  The subscribe link didn't show up until I went into the account and hunted down the subscribe options and turned it on.  

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.