I have a local piece of hardware that I access via it\'s IP address to retrieve json data.
I am creating a web based app but it can not access the local json data when t
As Brad mentioned using a proxy is the way to go. Here's some more information on proxies:
http://developer.yahoo.com/javascript/howto-proxy.html
If you have access to a php server, I can recommend the proxy by http://www.troywolf.com/articles/. You'll need the following:
If your url looks something like this http://<IPAddress>/RequestedJson then you might use flXHR which is quite convenient.
1) Import the libraries of flXHR
2) Simply create an instance of flXHR
3) Then assign it to jQuery Ajax options
$.ajaxSetup({
"xhr": myflXHRInstance
});
(more info in ajaxOptions page)
4)
Put crossdomain.xml in the root of your ip i.e.
http://<IPAddress>/crossdomain.xml More info about crossdomain.xml
5) Enjoy your crossdomain requests via jQuery ))
P.S. Requires the flash plugin to be installed. There are almost no browsers that do not have Flash player plugin installed. Riastats
EDIT: Sorry for russian link for crossdomain.xml.
Crossdomain.xml example
You can create a local proxy.
For example, if your web app is running at www.example.com, make a small server-side component that responds at www.example.com/hardware.
Then, upon calling this URL the server-side component performs a direct query to the hardware and returns it to the calling webapp.
Things to note:
You can proxy it with a PHP/ASP/etc. page on your local site that (in the back-end) will query the remote information. This will allow you to call somesite.com/getForeignData (which actually calls othersite.com/foreignData) and return it within the same domain.
Other than that, you're going to need to use JSONP (this is a boundary purposely set). The "last" option is to enable cross-boundary calls on your browser, but if you want others to have the same ability, this is only a temporary solution.
Can you add header to the HTTP Response? If yes, add the following
Access-Control-Allow-Origin
with the value *
then your browser will allow the request for that resource