473,226 Members | 1,563 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,226 software developers and data experts.

Synchronous Cross-Domain Request without Proxy

Hi All,

An experiment i'm doing requires requires a synchronous cross-domain
request, without using a proxy. I wondered if anyone had any ideas to
help me achieve this.

Below is what I have tried, including my conclusions/assumptions
(which i'll happily be corrected on if it solves my problem!):

The requirement not to use a proxy means I can't use the synchronous
mode of XMLHttpRequest, as it will not let me go cross-domain.

On-demand loading of javascript enables me to achieve the cross-domain
request by loading javascript of the form:

callback(data);

which on loading calls callback(), but it is not obvious how to make
this synchronous. I've also managed to get the same effect using a
hidden IFRAME, but again it relies on a callback. Is there a good way
to wrap/transform this in to a synchronous request?

The closest solution i've found which can probably solve it is the
narrative js (http://neilmix.com/narrativejs/doc/index.html), which
pre-processes javascript to turn a "yeild" function in to co-routines,
but this is getting a little scary/heavyweight!

Regardless of the actual implementation, the model i require is:

x = foo.bar();

where bar() returns a value based in part on the result of a cross-
domain request. i.e. the programmer doesn't care about the
implementation of bar(); it may be a standard method call, or may
include one or more cross-domain requests. The implementation details
must be hidden, hence at this level it appears as a normal blocking
call (i.e the solution is not "synchronous calls are evil, you should
be using asynchronous!").

Any ideas, pointers or suggestions would be very useful!

Thanks,
Simon

May 31 '07 #1
6 8520
Simon wrote:
Hi All,

An experiment i'm doing requires requires a synchronous cross-domain
request, without using a proxy. I wondered if anyone had any ideas to
help me achieve this.

Below is what I have tried, including my conclusions/assumptions
(which i'll happily be corrected on if it solves my problem!):

The requirement not to use a proxy means I can't use the synchronous
mode of XMLHttpRequest, as it will not let me go cross-domain.

On-demand loading of javascript enables me to achieve the cross-domain
request by loading javascript of the form:

callback(data);

which on loading calls callback(), but it is not obvious how to make
this synchronous. I've also managed to get the same effect using a
hidden IFRAME, but again it relies on a callback. Is there a good way
to wrap/transform this in to a synchronous request?

The closest solution i've found which can probably solve it is the
narrative js (http://neilmix.com/narrativejs/doc/index.html), which
pre-processes javascript to turn a "yeild" function in to co-routines,
but this is getting a little scary/heavyweight!

Regardless of the actual implementation, the model i require is:

x = foo.bar();

where bar() returns a value based in part on the result of a cross-
domain request. i.e. the programmer doesn't care about the
implementation of bar(); it may be a standard method call, or may
include one or more cross-domain requests. The implementation details
must be hidden, hence at this level it appears as a normal blocking
call (i.e the solution is not "synchronous calls are evil, you should
be using asynchronous!").

Any ideas, pointers or suggestions would be very useful!

Thanks,
Simon
Hi Simon,

Why don't you solve such issues serverside?
With PHP eg.
You can use AJAX if you want to call a PHP script on your own domain, let
that script fetch whatever it is you need, and return the result, formatted
as you like, to the browser?

I am maybe an oldfashioned guy, but use javascript for inside your browser
to manipulate stuff in there, and use a serverside solution when the need
arises.

I think you try to circumvent the cross-domain blocking.

Regards,
Erwin Moller
May 31 '07 #2
Hi Erwin,

Thanks for the reply.
Why don't you solve such issues serverside?
Because the browser/client can see both hosts, but the hosts can't see
each other. i.e. it is not possible to use one host as a proxy for
another.

I'm open to any ideas!

Simon

May 31 '07 #3
Simon wrote:
Hi Erwin,

Thanks for the reply.
>Why don't you solve such issues serverside?

Because the browser/client can see both hosts, but the hosts can't see
each other. i.e. it is not possible to use one host as a proxy for
another.
Hi Simon,

Are you sure the hosts cannot see each other?
If you want a javascript solution, the hosts must be reachable via http.
If they both have a http-server, you can (under most circumstances) do
something simple as:
$content = file("http://www.host1.com/something.html");

from php serverside.
That will fetch the full content of that page.

Are you sure the hosts cannot find each other but a browser can?

Regards,
Erwin Moller

>
I'm open to any ideas!

Simon
Jun 1 '07 #4
VK
On May 31, 1:09 pm, Simon <simon.a.f...@googlemail.comwrote:
The requirement not to use a proxy means I can't use the synchronous
mode of XMLHttpRequest, as it will not let me go cross-domain.
Not directly, because it would break cross-domain security. Still you
may use XHR combined with WSDL (Gecko) and WS (Microsoft) to use Web
services from different servers. WSDL (Web Service Description
Language) and WS (Web Services) are based on the same principles but
alas and as usual they are made to be as incompatible with each other
as possible, so a wrapper interface will be needed.
An OT note: same as in the VML - SVG case this is W3C only to blame
IMO, with their childish practice to take some long existing Microsoft
technology and then quickly write the same but with all words changed
and twisted around - so that would be always a standard and a non-
standard behavior of IE. This irritating practice seems going away
though.

Next you can use runtime <scriptblock insertion where the script
code would be generated by server and contain needed data in say JSON
format. This method is the most widely used and there is a number of
libraries to take care of different UA-specific issues.

For the last option you may use JSONet library for cross-domain data
exchange using CSS
http://jsnet.sourceforge.net/
Truly it never was in use on a corporate level. I merely made it as an
alternative to <scriptinsertion after I saw the US patent #6,941,562
development last year, so it was more of a message to the patent
holders: that Eolas-like community black lettering will not go. Yet
the library is fully operable and cross-UA tested.

Jun 2 '07 #5
Are you sure the hosts cannot see each other?
If you want a javascript solution, the hosts must be reachable via http.
If they both have a http-server, you can (under most circumstances) do
something simple as:
$content = file("http://www.host1.com/something.html");

from php serverside.
That will fetch the full content of that page.

Are you sure the hosts cannot find each other but a browser can?
Yeap, afraid so! Thanks anyway ;o)

Jun 4 '07 #6
Next you can use runtime <scriptblock insertion where the script
code would be generated by server and contain needed data in say JSON
format. This method is the most widely used and there is a number of
libraries to take care of different UA-specific issues.
This seems the best approach to use so far. Is there a way to wrap
this approach up in to what appears externally as synchronous call?

Jun 4 '07 #7

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

Similar topics

1
by: Noel | last post by:
Hi, I am a tad confused about if there are any benefits from using asynchronous vs synchronous network communication. As my example, I have been writing a dns lookup stack with a network...
1
by: Chris | last post by:
Hi. I have a ibrary I'm trying to use via javascript within IE. This library uses an asynchronous model where I call into a function and pass it a callback function as one of its arguments. My...
9
by: David | last post by:
Hello I'm testing the XMLHttpRequest object in Firefox and IE. The code below works well in IE and Firefox. It shows "1" when the string is a number and "0" when not. The page aspxTest.aspx only...
15
by: Javier Estrada | last post by:
Can someone explaing the difference between these exception models regarding the structured exception handling? The documentation is not clear. Some code would actually help. Thx
1
by: Shri Shrikumar | last post by:
Hi All, I am not sure if this is the right list for this question, so if its not, I would appreciate a pointer in the right direction. Anyways, I would like to know if triggers are synchronous...
3
by: Pro1712 | last post by:
Hi, this may be a stupid question: How can I can call the DoWork-function of a BackgroundWorker synchronous? Or in other words: How can I extend the BackgroundWorker class with a function...
4
by: Ryan Liu | last post by:
TcpClient has a method called GetworkStream GetStream(); So in other words, there is only one stream associate with it for input and output, right? So while it is receiving, it can not send, and...
1
by: Walther W | last post by:
Hello, Is it possible to make a synchronous Web Service? I have a situation where quite big piece of data should be send from client to Web Service server but client and server should not...
1
by: AECL_DEV | last post by:
Hello Everyone, Ive seen alot of people saying that the best way to AJAX Validate a form is through the submit button, because validation should be synchronous. Im wondering, is there any good...
0
ammoos
by: ammoos | last post by:
hi friends pls help me.. i got an assignment which i feel very difficult to me.. i dont have more knowledge about multi-threading in .net... the assignment details is below.... pls help me... i...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.