Buenas noches,
estoy utilizando Arduino YUN, he subido el sketch de ejemplo>Bridge->Bridge al que le he añadido debajo de la linea 42 y 43 Bridge.put("estado", "activo"); quedando así;
...
linea 42 server.listenOnLocalhost();
linea 43 server.begin();
linea 44 Bridge.put("estado", "activo");
...
La cuestíón es que cuando intento desde otra dirección local 192.168.1.15 acceder desde el navegador mediante código ajax me da un error de este tipo:
Failed to load http://192.168.1.16/data/get: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 400.
Sin embargo cuando pongo en la url: http://192.168.1.16/data/get me devuelve:
{"value":{"estado":"activo"},"response":"get"}
El código ajax que me da error es:
$.[b]ajax[/b]({
type: "GET",
dataType: "json",
url: "http://192.168.1.16/data/get",
headers: {
'Content-Type': 'application/json'
},
success: function(data){
alert("Correcto");
},
error: function () { alert("error"); },
});
Me podría alguien orientar, y como podría obtener todos los datos mediante http://192.168.1.16/data/get en ajax, es fundamental que sea así para mi proyecto.
Que estoy haciendo mal?
Muchas gracias.