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.
Results 1 to 7 of 7
  1. #1
    Sim
    Sim is offline
    New Coder
    Join Date
    Feb 2009
    Posts
    82
    Thanks
    1
    Thanked 1 Time in 1 Post

    Using jQuery across different servers

    My code works fine on my own server, but I want people to place a piece of JS on there site which will then call the php file on my server and display different results. I keep getting "Access Denied" is there any sort of work-a-round for this?
    Online RPG Creator - Create Your Own Online RPG with no programming knoweldge

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,726
    Thanks
    6
    Thanked 1,013 Times in 986 Posts
    JavaScript does not allow access to files on different hosts; this is called the same origin policy. The only way would be to put an iframe (dynamically with JS) and load your content there. That’s how Facebook and the like are doing it anyway.

  • #3
    Sim
    Sim is offline
    New Coder
    Join Date
    Feb 2009
    Posts
    82
    Thanks
    1
    Thanked 1 Time in 1 Post
    Would json be able to do it?
    Online RPG Creator - Create Your Own Online RPG with no programming knoweldge

  • #4
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    You probably mean JSONP.

    Yes, you can do it with JSONP.

  • #5
    Sim
    Sim is offline
    New Coder
    Join Date
    Feb 2009
    Posts
    82
    Thanks
    1
    Thanked 1 Time in 1 Post
    Could you point me a tutorial for JSONP??
    Online RPG Creator - Create Your Own Online RPG with no programming knoweldge

  • #6
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    This here seems to cover all you have to know:
    http://www.ibm.com/developerworks/library/wa-aj-jsonp1/

    It uses jQuery, but that's probably not a bad thing.

  • #7
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by venegal View Post
    This here seems to cover all you have to know:
    http://www.ibm.com/developerworks/library/wa-aj-jsonp1/

    It uses jQuery, but that's probably not a bad thing.
    maybe this will help too:

    http://www.w3.org/TR/cors/

    best regards


  •  

    Posting Permissions

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