Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- var ComprobarSeleccion = false;
- $('input[type=radio]').click(function(){
- ComprobarSeleccion = true;
- var request = $.ajax({
- url: "cuestionario.php",
- type: "POST",
- data:{ valor: this.value, verificar:ComprobarSeleccion},
- dataType:'text',
- jsonp:"jsoncallback",
- crossDomain: true,
- cache: false
- });
- request.done(function(data){
- if(data.estado=="seleccionado"){
- alert("Exito");
- unselect();
- //uncheckRadio(this);
- }else{
- alert(data.estado);
- alert("Error");
- }
- });
- request.fail(function( textStatus ) {
- alert( "Error en la petición: " + JSON.stringify( textStatus));
- });
- });
- });
- $datos = array();
- $a = false;
- if(isset($_GET['verificar']) && !empty($_GET['verificar'])){
- if($_GET['verificar']){
- $valor = $_GET['valor'];
- $a = true;
- $datos["estado"] = "seleccionado";
- }else{
- $datos["estado"] = "error123";
- $a = true;
- }
- }
- if($a == true){
- $resultadoJson = json_encode($datos);
- echo $_GET['jsoncallback'] . '(' . $resultadoJson . ');';
- }
- $sql .= "INSERT INTO respuestas (id_alumno, id_pregunta, respuesta)
- VALUES ('$id_alumno',$id_pregunta,'$respuesta')";
Add Comment
Please, Sign In to add comment