Connecting Tech Pros Worldwide Forums | Help | Site Map

cross domain XHR

Andrew Poulos
Guest
 
Posts: n/a
#1: Nov 20 '08
If I want to send an XHR request to a different domain without expecting
a response is this possible? I've started looking into cross domain
security issues with AJAX and I'm unsure what gets restricted.

I'm building an elearning course that runs on one server and is to
notify a different server each time the course is completed.

Andrew Poulos

Stor Ursa
Guest
 
Posts: n/a
#2: Nov 21 '08

re: cross domain XHR


Because of Browser Security there is no way of sending a Request to a
server other than the one hosting the page. In IE there is a setting
to allow you to turn off that Security, but it would be a pain in the
butt to ask your user to go to Tools Internet Options, and then
require all your user's to only use IE.

The best way I've found to do this is send a request to the server you
are hosting the page on, and let that server redirect the request to
the other server.

If you are using .NET take a look at the WebRequest class.
If you are using Java take a look at the URLConnection and
HttpURLConnection classes.
Other server-side languages should provide similar functionality.
Bart Van der Donck
Guest
 
Posts: n/a
#3: Nov 21 '08

re: cross domain XHR


Andrew Poulos wrote:
Quote:
If I want to send an XHR request to a different domain without expecting
a response is this possible? I've started looking into cross domain
security issues with AJAX and I'm unsure what gets restricted.
>
I'm building an elearning course that runs on one server and is to
notify a different server each time the course is completed.
It's not possible in a default javascript/AJAX environment. But there
are workarounds. You could try AJAX Cross Domain, a Perl/CGI approach:

http://www.ajax-cross-domain.com/

--
Bart
Jason S
Guest
 
Posts: n/a
#4: Nov 21 '08

re: cross domain XHR


On Nov 20, 6:33*pm, Andrew Poulos <ap_p...@hotmail.comwrote:
Quote:
If I want to send an XHR request to a different domain without expecting
a response is this possible? I've started looking into cross domain
security issues with AJAX and I'm unsure what gets restricted.
I asked this question recently...
http://groups.google.com/group/mozil...8290ae88e2065f

if you control both servers, then you could use the "Access-Control:"
header to grant cross-site permission, but it's kinda new & you need
browsers that pay attention to the use of this header. Firefox 3.0
doesn't but 3.1 is supposed to.
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#5: Nov 21 '08

re: cross domain XHR


Andrew Poulos wrote:
Quote:
If I want to send an XHR request to a different domain without expecting
a response is this possible?
Request to a non-existing server. Otherwise there is a response to a
request, be it only one with an error status code.

What you really wanted to ask is answered by

var o = new Image();
o.src = "http://foo.example/notify?foo=bar";

which is probably way more compatible than XHR.
Quote:
I'm building an elearning course that runs on one server and is to
notify a different server each time the course is completed.
Another possibility is navigation in a hidden iframe.


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7@news.demon.co.uk>
Closed Thread


Similar JavaScript / Ajax / DHTML bytes