Newbie: Ajax permission'g question

H

hemant.singh

Hello all,
I am developing a solution(JS/Ajax+ruby) which will be hosted on say
domain x.com

now my client can be comg from any domain, all they need to do is

<!-- Magic script starts -->
<div id="mymagic">
<script src="http://x.com/javascripts/client.js" />
<script type='text/javascript'>
showThemReality();
</script>
</div>
<!-- Magic script ends -->

Now the client.js loaded from x.com is making a ajax connection to
x.com, is this a issue? If not than how to access x.com server scripts
from client.js? I am try'g and it is giving me permission denied
exception.

Any help/pointer will be greatly appreciated

TIA
Hemu
 
N

Neredbojias

To further the education of mankind, (e-mail address removed) vouchsafed:
Hello all,
I am developing a solution(JS/Ajax+ruby) which will be hosted on say
domain x.com

now my client can be comg from any domain, all they need to do is

<!-- Magic script starts -->
<div id="mymagic">
<script src="http://x.com/javascripts/client.js" />
<script type='text/javascript'>
showThemReality();
</script>
</div>
<!-- Magic script ends -->

Now the client.js loaded from x.com is making a ajax connection to
x.com, is this a issue? If not than how to access x.com server scripts
from client.js? I am try'g and it is giving me permission denied
exception.

You don't have your first script element properly closed.
(Group deja vu?)

As for the source of javascript files, one can normally call a .js file
from any domain.
 
H

hemant.singh

Neredbojias,
Thanks for your comments ...
1) Why first script element is not properly closed? As I am using same
element to close it, not sure if there is some mistake, please point
out
2) yes I know .js can be loaded from any domain, and this is pretty
good thingy, but now that loaded js from a different domain want to
make a xmlhttprequest connection to the domain it is loaded from, which
is different from the domain where html page is being loaded, and here
i get permission'g issue, any idea how to avoid it ?

TIA
 
H

Hywel Jenkins

Hello all,
I am developing a solution(JS/Ajax+ruby) which will be hosted on say
domain x.com

now my client can be comg from any domain, all they need to do is

<!-- Magic script starts -->
<div id="mymagic">
<script src="http://x.com/javascripts/client.js" />
<script type='text/javascript'>
showThemReality();
</script>
</div>
<!-- Magic script ends -->

Now the client.js loaded from x.com is making a ajax connection to
x.com, is this a issue? If not than how to access x.com server scripts
from client.js? I am try'g and it is giving me permission denied
exception.


You've come up against the cross-domain scripting browser security.
This has been around for a long time. I suspect googling for "ajax
cross domain security" will yield something helpful.
 
H

hemant.singh

Hywel
Thanks dude,
I think im leading to a solution soon, googlg won't help as they ask
for permission'g and all crazy stuff which is not practical in real
world, atleast not in mycase...
 
N

Neredbojias

To further the education of mankind, (e-mail address removed) vouchsafed:
Neredbojias,
Thanks for your comments ...
1) Why first script element is not properly closed? As I am using same
element to close it, not sure if there is some mistake, please point
out

Should be:

<script type="text/javascript" src="something.js"></script>

then:

<script type="text/javascript">
//code here
2) yes I know .js can be loaded from any domain, and this is pretty
good thingy, but now that loaded js from a different domain want to
make a xmlhttprequest connection to the domain it is loaded from, which
is different from the domain where html page is being loaded, and here
i get permission'g issue, any idea how to avoid it ?

I see. I don't know much about Ajax so didn't realize the situation.
Liked Hywel's answer though am not sure it can be done (normally).
 
H

Hywel Jenkins

Hywel
Thanks dude,
I think im leading to a solution soon, googlg won't help as they ask
for permission'g and all crazy stuff which is not practical in real
world, atleast not in mycase...

Quote properly when you respond to a post.

How about having some server-side PHP include get the JS for you?
Something like this:

<?php include("getclient.php"); ?>

Have getclient.php do something like

<?php include("http://x.com/javascripts/client.js"); ?>

client.js should include the opening and closing script tags. Of
course, the file could have any extension you like in that case, as it
will be downloaded, inline, to the client.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top