Guest User

Untitled

a guest
Jul 19th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. $(document).ready(function(){
  2. var ComprobarSeleccion = false;
  3. $('input[type=radio]').click(function(){
  4.  
  5. ComprobarSeleccion = true;
  6. var request = $.ajax({
  7. url: "cuestionario.php",
  8. type: "POST",
  9. data:{ valor: this.value, verificar:ComprobarSeleccion},
  10. dataType:'text',
  11. jsonp:"jsoncallback",
  12. crossDomain: true,
  13. cache: false
  14. });
  15.  
  16. request.done(function(data){
  17. if(data.estado=="seleccionado"){
  18. alert("Exito");
  19. unselect();
  20. //uncheckRadio(this);
  21. }else{
  22. alert(data.estado);
  23. alert("Error");
  24.  
  25. }
  26. });
  27.  
  28. request.fail(function( textStatus ) {
  29.  
  30. alert( "Error en la petición: " + JSON.stringify( textStatus));
  31. });
  32.  
  33. });
  34.  
  35. });
  36.  
  37. $datos = array();
  38. $a = false;
  39. if(isset($_GET['verificar']) && !empty($_GET['verificar'])){
  40. if($_GET['verificar']){
  41. $valor = $_GET['valor'];
  42. $a = true;
  43. $datos["estado"] = "seleccionado";
  44. }else{
  45. $datos["estado"] = "error123";
  46. $a = true;
  47.  
  48. }
  49. }
  50.  
  51. if($a == true){
  52. $resultadoJson = json_encode($datos);
  53. echo $_GET['jsoncallback'] . '(' . $resultadoJson . ');';
  54. }
  55.  
  56. $sql .= "INSERT INTO respuestas (id_alumno, id_pregunta, respuesta)
  57. VALUES ('$id_alumno',$id_pregunta,'$respuesta')";
Add Comment
Please, Sign In to add comment