Forum Moderators: open
This is a bit unusual in that the values I need are obtained by querying a networked PTZ camera in this manner:
http://example.com/test-cgi/com/need.cgi?query=position
Typical results returned to the querying browser are:
camera=1 pan=-88 tilt=8 zoom=2266 focus=514 iris=2259
I need to display these values on a webpage in a format different from the above, but I am having one devil of a time understanding how to "submit" the above URL and to subsequently assign the returned values to Javascript variables to allow me to do so.
The URL needs to be "submitted" from within a function, i.e. not from a user's press of a form button.
I know I am missing a series of processes that will be obvious to you, but for the life of me, I can't get a handle on this.
Thank you for your time,
Frank
Thanks again.
My situation is that the "server" that I need data from is in firmware with no way to add an asp file.
Can someone give me a hint to shed light on where I should be heading with this?
Thanks.
Frank
http://example.com/test-cgi/com/need.cgi?query=position
and the ajax reply will be the string
camera=1 pan=-88 tilt=8 zoom=2266 focus=514 iris=2259
Provided the data can be accessed via a URL the source of the data is not important, there is no need for special files on the server.
I do have an AJAX script working now! And when I run it in IE & FF directly from my PC's C drive it fetches the data from the camera URL (same domain as my PC). But when I run it from its domain (an external host), I get a "Permission denied" error in IE and from FF I get:
"Security Error: Content at http://example.com/testajax3.html may not load data from http://<my WAN IP>/test-cgi/com/need.cgi?query=position."
and
"Error: uncaught exception: [Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "http://example.com/testajax3.html Line: 40"]"
However, within the same HTML file that holds the AJAX script, I have an iframe with the same URL (including the WAN IP) as in the AJAX get statement and it displays the results properly. It seems AJAX isn't dealing with the cross-domain aspect of this, whereas the iframe does. Does that make any sense?
AJAX certainly appears to be appropriate for this application as per your advice. However, I'm not real sure I can get around this latest issue.
Thanks again for your time and support.
Frank
[edited by: DrDoc at 4:54 pm (utc) on April 8, 2009]
[edit reason] delinked example URI [/edit]
If it just for yourself and friends your can change you browser setting.
If just working with the latest browsers is Ok. I understand there are new meta tags that can be used to allow cross domain working, but as you can not change the server that is probably not an option.
google "cross domain ajax" will find other techniques but not sure any fit your case. Perhaps the "flash" solution.
As far as iframe is concerned, it seems to dispaly all right. But I know of know way to manipulate the data. I had been planning to build a graphic representation of camera position. So the iframe display does no good.
But AJAX is interesting. I appreciate your advice in that regard and plan to pursue it more. Also have heard about JQUERY and need to look into that.
Thanks again,
Frank
Iframes can achieve most of what newer AJAX methods do and is supported by older browsers, the cross domain restriction in this case accessing its content, you need something on the some domain to assist possibly a second iframe.
Thanks for the advice!
Frank
Thanks for the help.
Thanks for advice.... the document.domain function was a good one and seems appropriate, but I couldn't get access to the data. I believe the reason is that I have to use a port number on the IP. I have the WAN hitting a router and the camera and servers connect to the router. So I have to assign ports for forwarding.
Seems strange to think that getting the data from the camera in such a way that to do anything but display it is impossible! iFrame works for the display, but still no way to even format the iframe's content.
Thanks for your support Dave.
Frank
Can you give more details on the form of the urls you are using, is it same domain name, different port or whatever.
Is set up a proxy on the page server to forward data from camera server an option ?. This is a common workaround.
Alternatively the page server could access camera and do formatting server side.
Dave
The camera firmware server is WAN IP (example) 356.12.230.43:80 or LAN at 192.168.1.8
I am trying to get the camera GET data from a webpage stored on computer at WAN IP 356.12.230.43:81 / LAN 192.168.1.103
AJAX Get works fine when opening the php file in the browser from the PC (192.168.1.103) serving the webpage. But from another PC on the LAN side, 192.168.1.102, Permission Denied type errors are returned.
I don't yet understand the process of "proxy on the page server" or "formatting server side". However your two or three previous tips were very appropriate and showed great promise. So I look forward to understanding and experimenting with your most recent ideas. The "serving" PC runs Windows XP... It has no actual serving software. Perhaps that is a problem with your most recent proposed solutions (?)
Thanks for your interest Dave. Your comment of "common workaround" leads me to believe that you still think there is a way to do this.
Frank
[edited by: DrDoc at 4:56 pm (utc) on April 8, 2009]
[edit reason] replacing real IPs with bogus ones [/edit]
Is there a domain name server (DNS) setup on your network so that machines can be addressed by name rather than IP, where the name has two parts camera.example.com the subdomain (per machine) and the domain (per group of machines) ?
Then I have a redirect that points to the serving PC's port number... i.e. http://frank.example.com:83. So when my dynamic IP changes both redirects change as well (however my "dynamic IP" hasn't changed for well over a year). That redirect accesses the serving program on that PC.
Did I cover the full picture? And I can always change any of those if that would help. People really don't even access the camera using a redirect. People access the camera by going through my main webpage, which is an actual domain name... i.e. http://www.example.com, which is a php webpage residing on my host provider's server. On that page is a link to the server PC. Then on the program (WebCamXP) running on the server PC is an option to view the camera feed.
Thanks for your help with this Dave and for suffering through all of that!
Frank
[edited by: DrDoc at 4:59 pm (utc) on April 8, 2009]
[edit reason] examplifying URIs and IPs [/edit]