473,402 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

xmlHttpRequest is not working

I would like to use the xmlhttprequest-object to send an http request
to my server. The http request is used to switch the light on through
home automation.

However it's not working, and I can't find the problem.

Could it be that the apache-server is located on 192.168.0.21 and that
the http request is sent to 192.168.0.21:8080?

Thanks for your help.

Ivan

This is my code:

<script type="text/javascript">
var xmlhttp

function loadXMLDoc(eibMessage)
{
var url='http://192.168.0.21:8080/eibhomeserver?instruction=<eib
type="write" path="/eib/groups/' + eibMessage + '/curvalue" data="1"/>'
xmlhttp=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest()
}
// code for IE
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
}
if (xmlhttp!=null)
{
// alert(url)
xmlhttp.onreadystatechange=state_Change
xmlhttp.open("GET",url,true)
xmlhttp.send(null)
}
else
{
alert("Your browser does not support XMLHTTP.")
}
}

function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
{
// if "OK"
if (xmlhttp.status==200)
{
// ...some code here...
alert("loaded")
}
else
{
alert("Problem retrieving XML data")
}
}
} else {
alert(xmlhttp.readyState)
}
</script>

Jan 19 '07 #1
6 3765
ASM
eu*********@yahoo.com a écrit :
>
function loadXMLDoc(eibMessage)
{
var url='http://192.168.0.21:8080/eibhomeserver?instruction=<eib
type="write" path="/eib/groups/' + eibMessage + '/curvalue" data="1"/>'
I don't know what it is :

<eib type="write" path="/eib/groups/'+eibMessage+'/curvalue" data="1"/>'

nor what it is supposed to do
all rest seems OK
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Jan 19 '07 #2
eu*********@yahoo.com wrote:
I would like to use the xmlhttprequest-object to send an http request
to my server. The http request is used to switch the light on through
home automation.

However it's not working, and I can't find the problem.

Could it be that the apache-server is located on 192.168.0.21 and that
the http request is sent to 192.168.0.21:8080?
Check the JavaScript console? Do you get a permission denied error? The
same origin policy might prevent you from connecting to that port.
If all you want is to make a GET request then e.g.
var httpRequest = new Image();
httpRequest.src = 'http://example.com/whatever?arg1=val1&arg2=val2';
might suffice and not be restricted by the same origin policy.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 20 '07 #3
Thanks for your help. It was indeed a security issue.

I've solved it by adding a proxy in my apache configuration. So I
request a page from the same server, but apache forwards it to port
8080.

Thank you

Ivan

Jan 20 '07 #4
eu*********@yahoo.com wrote:
Thanks for your help. It was indeed a security issue.

I've solved it by adding a proxy in my apache configuration. So I
request a page from the same server, but apache forwards it to port
8080.
That's interesting. I know several folks who are involved in projects
related to system/home automation.

It looks like your automation softare is not running directly through
your standard web-server software (Apache?).

If not, running a reverse proxy through Apache would certainly do the
job -- I've used this method numerous times.

I am curious however as to the automation server software you're using
though. Currently I'm participating in the "ICP" (iCanProgram)
"Introduction to Linux Programming" course*. A package/API called
"SIMPL" is introduced during the course, and is referenced elsewhere on
the internet as being a capable home-automation tool.

Anyway, I'm just asking for knowledge's sake. Take care, best-of-luck,
and glad-you-found-a-solution! =)
- Scott.

* The course starts every couple of months (free with a donation to
your local Cancer Society) and can be found at:
http://www.icanprogram.com/43ux/main.html

Jan 20 '07 #5

eu*********@yahoo.com wrote:
Thanks for your help. It was indeed a security issue.

I've solved it by adding a proxy in my apache configuration. So I
request a page from the same server, but apache forwards it to port
8080.
So you are now really turning on your lights at home through a website?
Must be some fancy home admin page you have if you want Ajax for this.
I'm curious why you need to do this but maybe that's none of my
business.

Peter

Jan 20 '07 #6
FYI:

I'm using the EIB home automation which is a standard among 100 brands
(Siemens, Gira, Merten, ..). There are several open source programs
available to connect to the bus. I'm starting to use the eibcontrol
server.

This server responds to httprequests on port 8080.

Within the server there are some examples to shut on/off the lights,
but to avoid that the user shifts from the current page when sending an
httprequest, they use frames.

I prefer a more modern solution, so that why I as looking at the
xmlhttprequest-object.

My goal is to have a web-app so I can control lighting from the coach.
Remote control is not my goal, but it is possible. 5 min. ago a friend
was able to put on my lights. But ofcourse ... I still have to put
security in place.

To control the lights, I'll use the Nokia 770 web browser (or perhaps
the iPhone in a couple of years :-)

Ivan

Jan 21 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dominic Myers | last post by:
Hi there, I'm playing with XMLHttpRequest and followed the article by Bill Bercik at http://www.webpasties.com/xmlHttpRequest/... I'm having problems getting the last two steps to work though....
2
by: dx27s | last post by:
Hi all, I'm working with the XMLHttpRequest object. I receive the following error message: "Permission denied to call method XMLHttpRequest.open" This occurs in Firefox only. IE works fine. ...
20
by: chris.schwalm | last post by:
This is part II of this <a...
3
by: VK | last post by:
The Web API Working Group has released the First Public Working Draft of The XMLHttpRequest Object. <http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060405/> P.S. Finally some good movement...
1
by: 4levels | last post by:
Dear Folks, I stumbled upon a strange behaviour of the XMLHttpRequest.. Maybe I'm just not well informed enough about its possibilities, so could someone please confirm my question? When I...
13
by: TLaufenberg | last post by:
I'm new to Javascript programming and I've run into a bit of a snag with making an XMLHttpRequest in the Safari browser. Actually, the request doesn't work in Firefox either but only when I use a...
1
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest...
20
RMWChaos
by: RMWChaos | last post by:
Currently testing in: WinVista / IE7 I have been working on getting xmlhttprequest going for weeks now. I have finally gotten a semi-working script going. Pulling up text or xml files works great...
6
by: Patrick Nolan | last post by:
I'm working on cross-platform portability of some javascript. My Macintosh testing platform is rather old. It has Safari 1.3.2 and Internet Explorer 5.2. I got Safari working, but now IE is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.