data.php
Cita:
<?php
if (isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400');
}
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
}
include_once('libros.php');
$libros = new libros();
$varios = $libros->getJSONDatos();
$varios2= (string)$varios;
die($varios2); // or die(json_encode($varios2) ?
?>
if (isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400');
}
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
}
include_once('libros.php');
$libros = new libros();
$varios = $libros->getJSONDatos();
$varios2= (string)$varios;
die($varios2); // or die(json_encode($varios2) ?
?>
Cita:
<html>
<head>
<title></title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
</head>
<body>
<table width="100%" border="0">
<tr>
<td align="center" width="100%">
<label class="label label-primary">Realizacion de encuestas</label>
</td>
</tr>
</table>
<script type="text/javascript">
var cadena;
$.ajax({
method: "GET",
url : "http://192.168.0.5:8081/JSON/data.php",
success : function(h)
{
cadena = JSON.parse(h);
alert(cadena.status);
}
});
var msj = "Cargando";
alert(msj);
alert(cadena);
for( var i = 0; i < cadena.registro.length; i++ ) {
document.write("<div class=\"panel panel-default\"><div class=\"panel-heading\">"+
cadena.registro[i].Pregunta + "</div> <div class=\"panel-body\">");
for( var j = 0; j < cadena.registro[i].Respuestas.length; j++ )
{
document.write(" <div class=\"radio\"> <input type=\"radio\" name=\"optradio\"> "+cadena.registro[i].Respuestas[j]+"</div>");
}
document.write("</div></div></div>");
}
</script>
</body>
</html>
<head>
<title></title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
</head>
<body>
<table width="100%" border="0">
<tr>
<td align="center" width="100%">
<label class="label label-primary">Realizacion de encuestas</label>
</td>
</tr>
</table>
<script type="text/javascript">
var cadena;
$.ajax({
method: "GET",
url : "http://192.168.0.5:8081/JSON/data.php",
success : function(h)
{
cadena = JSON.parse(h);
alert(cadena.status);
}
});
var msj = "Cargando";
alert(msj);
alert(cadena);
for( var i = 0; i < cadena.registro.length; i++ ) {
document.write("<div class=\"panel panel-default\"><div class=\"panel-heading\">"+
cadena.registro[i].Pregunta + "</div> <div class=\"panel-body\">");
for( var j = 0; j < cadena.registro[i].Respuestas.length; j++ )
{
document.write(" <div class=\"radio\"> <input type=\"radio\" name=\"optradio\"> "+cadena.registro[i].Respuestas[j]+"</div>");
}
document.write("</div></div></div>");
}
</script>
</body>
</html>