...

View Full Version : json url problem



patrioticcow
12-27-2010, 08:19 PM
hello
i am using a json file to import some content into a div like this:

$.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:

$.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

devnull69
12-28-2010, 08:12 AM
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).

patrioticcow
12-28-2010, 06:09 PM
what if i do some kind of server authentication... is there a way like that?

patrioticcow
12-28-2010, 06:10 PM
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?

devnull69
12-28-2010, 06:27 PM
Right now you have the following options:
http://www.nathanm.com/ajax-bypassing-xmlhttprequest-cross-domain-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/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum