Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Regular Coder mlse's Avatar
    Join Date
    Mar 2005
    Posts
    624
    Thanks
    20
    Thanked 19 Times in 18 Posts

    Access Denied from Localhost

    Hi all,

    My use of AJAX is coming along nicely, BUT - I have noticed something strange! On my development machine, if I load a page on my local webserver (Apache 2 runing under Debian Etch) via it's IP address, AJAX works fine. However, when I load it via the L.O. (localhost), I get the javascript error uncaught exception: Permission denied to call method XMLHttpRequest.open.

    Weird.

    Any ideas, without seeing my code? I'll post if it will help.

    TIA,
    Mike.
    Last edited by mlse; 04-18-2008 at 12:45 PM.

  • #2
    Regular Coder Stooshie's Avatar
    Join Date
    Mar 2008
    Location
    Dundee, Scotland
    Posts
    380
    Thanks
    9
    Thanked 39 Times in 39 Posts
    If the server part of the url in the address bar is different to the server part of the address you are calling via AJaX then security permissions kick in.

    If you are loading the page initially using the IP address, then you should call the AJaX through that address.

    If you are using localhost then the same should be used for the AJaX.

    This may seem strange at first because they are essentially the same machine. The security settings don't know that localhost and your IP address are the same. Your IP address could change.
    Regards, Stooshie
    O

  • #3
    Regular Coder mlse's Avatar
    Join Date
    Mar 2005
    Posts
    624
    Thanks
    20
    Thanked 19 Times in 18 Posts
    Hi Stooshie, yep, I know that. All my calls are made using relative URLs so there shouldn't be a problem.

  • #4
    Regular Coder Stooshie's Avatar
    Join Date
    Mar 2008
    Location
    Dundee, Scotland
    Posts
    380
    Thanks
    9
    Thanked 39 Times in 39 Posts
    Sorry will have to log off soon so might not be able to respond very soon. I'll ask you this anyway.

    What browser are you using? If you are using firefox, you may need this link:

    How to fix ajax error

    If that's not the case do you access the internet via a proxy? I know that sounds daft when you are accessing localhost, but my work pc needs to go through the proxy to access my localhost server. If this is the case, then the proxy may be returning the code as if it from the IP address even when you have localhost in the address bar. In which case, the quick solution is just to use the IP address.

    Hope that is some help.
    Regards, Stooshie
    O

  • #5
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    by default in the security settings (for windows based machines anyways) localhost is in the restricted zone, adjust your security settings in internet explorer under zones.
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender

  • #6
    Regular Coder mlse's Avatar
    Join Date
    Mar 2005
    Posts
    624
    Thanks
    20
    Thanked 19 Times in 18 Posts
    Hi all,

    Thanks for your replies! I have no proxy, nor am I using IE ... I've put in a quick fix by getting localhost to redirect to the local IP address.

  • #7
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    internet explorer doesn't itself matter, the security zones setting, however, is easily accessible through internet explorer's options
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender

  • #8
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by mlse View Post
    Hi all,

    Thanks for your replies! I have no proxy, nor am I using IE ... I've put in a quick fix by getting localhost to redirect to the local IP address.
    I guess the problem is:

    ls -l myscript.php
    .... -r--r--r-- ... myscript.php

    but must be:
    .... -rw--r---r--- ... myscript.php

    fix with:
    chmod u+w myscript.php

    regards

  • #9
    Regular Coder mlse's Avatar
    Join Date
    Mar 2005
    Posts
    624
    Thanks
    20
    Thanked 19 Times in 18 Posts
    Hiya, nope, all my scripts have 644 permissions!

    I have the work-around so thanks anyway

  • #10
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by mlse View Post
    Hiya, nope, all my scripts have 644 permissions!

    I have the work-around so thanks anyway
    I'm glad you solve it. Please post the way you fix it for future search on forum. Could help someone Thank you.

    regards

  • #11
    Regular Coder Stooshie's Avatar
    Join Date
    Mar 2008
    Location
    Dundee, Scotland
    Posts
    380
    Thanks
    9
    Thanked 39 Times in 39 Posts
    It's ok oesxyl, he did earlier.

    Quote Originally Posted by oesxyl View Post
    I'm glad you solve it. Please post the way you fix it for future search on forum. Could help someone Thank you.

    regards

    Quote Originally Posted by mlse View Post
    Hi all,

    Thanks for your replies! I have no proxy, nor am I using IE ... I've put in a quick fix by getting localhost to redirect to the local IP address.
    Regards, Stooshie
    O

  • #12
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Stooshie View Post
    It's ok oesxyl, he did earlier.
    Thank you, and I'm sorry, some times I'm dumb, I read the post but don't get the message,

    regards

  • #13
    Regular Coder mlse's Avatar
    Join Date
    Mar 2005
    Posts
    624
    Thanks
    20
    Thanked 19 Times in 18 Posts
    Lol! Anyway, it looks like that's going to be a permanent fix now rather than a quick fix!

  • #14
    Regular Coder Stooshie's Avatar
    Join Date
    Mar 2008
    Location
    Dundee, Scotland
    Posts
    380
    Thanks
    9
    Thanked 39 Times in 39 Posts
    Just realised mlse, I said "he". I hope I wasn't making assumptions.
    Regards, Stooshie
    O

  • #15
    New Coder
    Join Date
    Nov 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm having the same problem as mlse, but I've tried everything I could find on the internet to solve my permissions problem with no success.

    I'm using Windows XP Pro SP2 (32 bit, IIS 5) and I've tried the following:

    The above suggestion of making localhost a trusted site;
    1. I made sure that my localhost is a trusted site (as suggested above);
    2. Tried to use my own IP address instead of localhost;
    3. I set my folder to be Shared and allow other users to change my files;
    4. I made sure my folder was set with full permissions to everyone (as suggested here;
    5. In IIS, I checked Anonymous login and made sure that the login is my username;
    6. Shared the folder, and also set it shared to internet users;


    ...and I still can't save files using an upload form. I keep getting an access denied error. I know that it's my own machine because my script works fine in other environments. Did I miss anything?


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •