Récupérer du JSON en cross domaine avec localhost
Le code suivant marche très bien si ma page.html se trouve dans ou en dehors du dossier www :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
getJSON function
<script>
$(document).ready(function () {
//$.getJSON('http://feeds.delicious.com/v2/json/popular?callback=?', function(data) {
alert("data : "+data);
});
});
</script>
</body>
</html> |
Sauf que si je change l'url précédant par :
Code:
$.get('http://localhost:8080/json?callback=?', function(data) { ...
ça continue à marcher uniquement si ma page.html se trouve dans le dossier www. En dehors du dossier ça ne marche plus.
Un problème avec le domaine localhost?