Hi any chance this could be added to HTTP in as this would allow Ajax updates to planner. Ajax seems to work fine desktop browsers, but soon stops after a few attempts on iOS iphone/pad.
I think Safari on iOS doesn’t deal well with the error
XMLHttpRequest cannot load https://api.electricimp.com/v1/[id]/[id]?value=31.
Origin https://[my site] is not allowed by Access-Control-Allow-Origin.
My understanding all is need is the response header needs to return
Access-Control-Allow-Origin: [request site host name] or “*”
If you need a way around, you can have your javascript make a request back at the server that served you the javascript, then use a server-side language like PHP to handle the cross-domain request. Here’s a simple (hacky) php script that will pass the value along (POST the value to the php script):
Thanks I completely misunderstood cross-origin thinking I had to put the html page! That said chrome seems to allow cross-origin when using Ajax call’s to HTTPin on e.imp. Can’t wait for Agents.
You can also use the “Access-Control-Allow-Origin” header (see this post).
While our examples typically use “Access-Control-Allow-Origin: *” - this can be somewhat dangerous. You can also specificy a specific domain to allow the requests to come from - so if your webpage’s URL that is communicating with teh agent is foo.com, you can set a header in the response to say “Access-Control-Allow-Origin: foo.com”