473,396 Members | 2,085 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,396 software developers and data experts.

xmlHTTPRequest problem

Ive been playing around with xmlHTTPRequest and was wondering if i was
programming a part of my code wrong.

what i want to do is have the browser access another part of my site
using xmlhttprequest.

however, when i use xmlhttp.open("POST",
'http://xml.mysite.com/test.php')
it fails, but if i use xmlhttp.open("POST",
'http://www.mysite.com/test.php') it works. Is access to another url
restricted in xmlhttp?

thanks in advance.

Sep 12 '05 #1
4 1986
"David Wang" <da******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Ive been playing around with xmlHTTPRequest and was wondering if i was
programming a part of my code wrong.

what i want to do is have the browser access another part of my site
using xmlhttprequest.

however, when i use xmlhttp.open("POST",
'http://xml.mysite.com/test.php')
it fails, but if i use xmlhttp.open("POST",
'http://www.mysite.com/test.php') it works. Is access to another url
restricted in xmlhttp?


Yes!

Cross-domain access is restricted in JavaScript.
You *might* be able to step out of the sandbox by signing your script,
but I have never tested that myself. (I do it quite often with
signed Java Applets, thou...).

--
Dag.
Sep 12 '05 #2
"Dag Sunde" <me@dagsunde.com> wrote in message
news:jl*******************@juliett.dax.net...
"David Wang" <da******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Ive been playing around with xmlHTTPRequest and was wondering if i was
programming a part of my code wrong.

what i want to do is have the browser access another part of my site
using xmlhttprequest.

however, when i use xmlhttp.open("POST",
'http://xml.mysite.com/test.php')
it fails, but if i use xmlhttp.open("POST",
'http://www.mysite.com/test.php') it works. Is access to another url
restricted in xmlhttp?


Yes!

Cross-domain access is restricted in JavaScript.
You *might* be able to step out of the sandbox by signing your script,
but I have never tested that myself. (I do it quite often with
signed Java Applets, thou...).


Forgot...

You can make a proxy script on 'http://www.mysite.com/test.php', that
calls 'http://xml.mysite.com/test.php' on the server side and returns
the result.

--
Dag.
Sep 12 '05 #3


David Wang wrote:
Ive been playing around with xmlHTTPRequest and was wondering if i was
programming a part of my code wrong.

what i want to do is have the browser access another part of my site
using xmlhttprequest.

however, when i use xmlhttp.open("POST",
'http://xml.mysite.com/test.php')
it fails, but if i use xmlhttp.open("POST",
'http://www.mysite.com/test.php') it works. Is access to another url
restricted in xmlhttp?


Yes, general with client-side scripting there are restrictions falling
under the "same origin policy" although that term has had a meaning
before XMLHttpRequest existed.

As for your particular problem in theory it could help to set
document.domain = 'mysite.com';
before you try your request as in your special case you do not want to
access a completely different domain but a subdomain.
I say in theory as that approach with setting document.domain was
introduced for cross frame scripting and I am not sure whether it
applies to XMLHttpRequest implementations as well.
You could try with your domain/sub-domains and report back whether that
improves things.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 12 '05 #4
it looks as if modifying document.domain DOES NOT work. i ended up
just leaving the script in another directory. =(

Sep 13 '05 #5

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

Similar topics

6
by: Chris Smith | last post by:
This is a bit of a weird problem. Unfortunately, I can't reproduce it in a simple example, so I can only poke it out there and see if anyone has seen something similar. I have a script that...
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....
10
by: Matt Kruse | last post by:
I'm aware of the circular reference memory leak problem with IE/closures. I'm not sure exactly how to resolve it in this situation. Also, Firefox appears to grow its memory size with the same code....
42
by: Greg | last post by:
Hi, I've designed a bookmark in Ajax / PHP that I will put soon on sourceforge.net. But I've got an very tricky bug. I try it on some computers with Internet Explorer/Windows, Firefox...
1
by: weston | last post by:
So, the following apparently works as a method of grafting a method onto an object (using the squarefree JS shell): obj = { x: 1, inc: null } result obj.inc = function () { this.x++ } result...
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: vocalise | last post by:
The title probably isn't very clear, but I haven't been able to find this problem (or I must be having problems figuring out which search strings to use) so I apologize if this has been addressed...
1
by: Charlie | last post by:
I am trying to make an XMLHttpRequest which violates the default "same- origin"policy in Firefox. I checked the archives and found a method that should work but it does not. Below is the test code...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.