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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    json url problem

    hello
    i am using a json file to import some content into a div like this:
    Code:
    $.getJSON('json/main_profile.json', function(data) {
     $('#info_title').html(
    '<h1>' + "General Information " + '</h1>'
    );
    });
    but the problem appears when i try to replace the json file with a url, like this:
    Code:
    $.getJSON("http://interfaces-server.insource.local/users/145198", function(data) {
     $('#info_title').html(
    '<h1>' + "General Information " + '</h1>'
    );
    });
    why works with the file but not with the link??

    thanks

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    Do you try to get the JSON file from an external server? Then the script is violating the SOP (same origin policy). You can not get data via AJAX from an external source (different domain than the current page).

  • #3
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what if i do some kind of server authentication... is there a way like that?

  • #4
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by devnull69 View Post
    Do you try to get the JSON file from an external server? Then the script is violating the SOP (same origin policy). You can not get data via AJAX from an external source (different domain than the current page).
    what if i do some kind of server authentication... is there a way like that?

  • #5
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    Right now you have the following options:
    http://www.nathanm.com/ajax-bypassin...n-restriction/

    With XMLHttpRequest Level 2 you will be able to have some kind of "trusted server" for your app
    http://www.w3.org/TR/XMLHttpRequest2/


  •  

    LinkBacks (?)


    Posting Permissions

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