Foros del Web » Programando para Internet » Javascript » Frameworks JS »

Problema al llamar una funcion ajax

Estas en el tema de Problema al llamar una funcion ajax en el foro de Frameworks JS en Foros del Web. Buenas tengo el siguiente problema yo llamo una funcion en javascript que a su vez llama a una funcion que tengo de ajax el codigo ...
  #1 (permalink)  
Antiguo 13/07/2009, 18:01
 
Fecha de Ingreso: mayo-2008
Ubicación: Sevilla - España
Mensajes: 140
Antigüedad: 16 años
Puntos: 1
Problema al llamar una funcion ajax

Buenas tengo el siguiente problema yo llamo una funcion en javascript que a su vez llama a una funcion que tengo de ajax el codigo es este
Código HTML:
<html>
<head>
<title>Agregar evaluaciones</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type='text/javascript' src='Ajax/Ajax.js'></script>
<script language="JavaScript">
var swChek=0;

function chequeatutor(texto){
if(texto =="") return false;
return true;
}

function chequeaFormulario(){
var valido = true;
var NombreEval = window.document.resultado.nombreEval.value;
var IdTema=window.document.resultado.tema.options[window.document.resultado.tema.selectedIndex].value;
//alert(IdTema);
ValidarTema(IdTema);

valido = valido && chequeatutor(NombreEval);
if(!valido){
alert("Por Favor ingrese un nombre para la evaluacion");
return false;
}
if(swChek==0){
	alert("Tiene que inscribir al menos 1 preguntas");
	return false;
}



return true;
}

function validarCheck(check){

	if(check.checked){
		document.resultado.ides.value += check.value + "|";
		swChek++;
	}else{
		var x = document.resultado.ides.value.split(check.value + "|");
		document.resultado.ides.value = x.join("");
		swChek--;
	} 
	 //alert("Hello");
   //alert(document.resultado.ides.value);
}
</script>
<style type="text/css">
<!--

.consulta1{
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
	font-weight:bold;
	color: #000;
	background-color:#FFF;
	
}
.consulta2{
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
	font-weight:bold;
	color: #FFF;
	background-color:#ea8a00;
	
}
.encabezado{
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
	color: #FFF;
	background-color:#ea8a00;
}
.enlace{
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
	font-weight:bold;
	color: #FFF;
	text-decoration:none;
}
.enlace2{
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
	font-weight:bold;
	color: #FFF;
	text-decoration:underline;
}
.Contenido1{
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
	font-weight:bold;
	color: #000;
	text-decoration:none;
}
.Contenido2{
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
	font-weight:bold;
	color: #000;
	text-decoration:underline;
}
-->
</style>
<script LANGUAGE='JavaScript'>
	  function redireccionar(pagina){
		 location.href=pagina;
		 //location.href=pagina;
		 }
</script>
</head>
<body bgcolor="black" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- Save for Web Slices (UsuarioProfesor.psd) -->
<table id="Tabla_01" align="center" width="900" height="800" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td>
			<img src="../imagenes/UsuarioProfesoresperemosqueestesi_01.gif" width="900" height="129" alt=""></td>
	</tr>
	<tr>
		<td>
        
  <div style="background-image:url(../imagenes/UsuarioProfesoresperemosqueestesi_02.gif); background-repeat:no-repeat; width:900px; height:608px;">
  <div style="position:absolute; left: 824px; top: 134px; width: 97px;">
 <a href="Menu_Profe.php" onMouseOver="this.className='enlace2'" onMouseOut="this.className='enlace'" class="enlace">Volver al menú</a>
  </div>

    <div style="position:absolute; left: 696px; top: 168px; width: 306px; font-family:arial; color:#FFF; font-size:10px; font-weight:bold">
    <p>Bienvenido Profesor, <? echo $_SESSION['NombreUsuario']." ".$_SESSION['Apellido']; ?></p>
</div>
  <div style="position:relative; left: 250px; top:150px; height: 40px; width:487px; font-family:Arial, Helvetica, sans-serif; color:#FFF; font-size:12px; font-weight:bold; text-align:center">
  <?

	 include("../Modelo/conectar.php");
     include("../Controladores/Preguntas.php");
	 include("../Controladores/Temas.php");
	 include("../Controladores/Evaluaciones.php");
	 $bd = new conectar();
     $Preg=new Preguntas();
	 $Tema=new Temas();
	 $Eval=new Evaluaciones();
     $bd->conectarse();
	 $Preg->setConexion($bd->getConexion());
	 $Tema->setConexion($bd->getConexion());
	 $Eval->setConexion($bd->getConexion());
	 $swVer=0;
	 //INGRESO A LA BD
	 if(isset($_POST['IngresarEvaluacion'])){
		 $IdTema=$_POST['tema'];
		 $NombreEvaluacion=$_POST['nombreEval'];
		 $VectorId=explode("|",$_POST['ides']);
         $limite=count($VectorId)-1;
		 $Eval->setIdTema($IdTema);
		 $Eval->setNombre($NombreEvaluacion);
		 $Aprobacion=$Eval->IngresarEvaluaciones();
		 if(empty($Aprobacion)){
			 $IdEval=mysql_insert_id($Eval->getConexion());
			 for($i=0;$i<$limite;$i++){
				$Preg->setIdEvaluacion($IdEval); 
				$Comprobacion=$Preg->ModificarPreguntas($VectorId[$i]);
				if(empty($Comprobacion)){
					$swVer++;
				}//empty comprobacion
			 }//for
			 if($swVer==$limite){
				 ?>
              <script>
			 alert("Evaluacion ingresada satisfactoriamente");
			 </script>
                 <?
			 }//fin comparacion sw == limite
			 else{
				  ?>
              <script>
			 alert("hubo un error");
			 </script>
                 <?
			 }//else comparacion sw == limite 
		 }//fin empty Aprobacion
		 else{
			 ?>
			 <script>
			 alert("Hubo un error");
			 </script>
			 <?
		 }//fin else aprobacion
	 }//fin isset
	 ////FINISH
	 $Sql=$Tema->ConsultarNombreTemas();
	 if (!isset($pag)) $pag = 1;
     $tampag = 10;
	 $Sql2=$Preg->ConsultarPreguntas($pag,$tampag);
	 ?>
    
 <table bgcolor="#ea8a00" width="490" height="170">
 <tr>
 <td id="recibirAjax">
 </td>
 </tr>
   <tr>
    <td>
    <form  method="post" name="resultado" target="_self">
    <table width="267" height="123" border="1" align="center" bgcolor="#FFFFFF" style="border:ridge">
    <tr class="encabezado" align="left">
    <th>
    Elija un tema para la evaluación
    </th>
    </tr>
        <tr>
        <td>
        <select name="tema">
       <? while($MostrarFila=mysql_fetch_array($Sql)){ ?>
        <option <? echo"value='".$MostrarFila['id']."'";?> ><? echo $MostrarFila['Nombre']; ?></option>
         <? }?>
        </select>
        </td>
        </tr>
        <tr>
        <th class="encabezado" align="left">
        Ingrese un nombre para la evaluación
        </th>
        </tr>
        <tr>
        <th align="left">
        <input type="hidden" name="ides"> 
       <input name="nombreEval" type="text" size="37">
        </th>
        </tr>
         <tr>
        <th class="encabezado" align="left">
        Elija Las preguntas de la evaluación
        </th>
        </tr>
         <tr>
        <td >
       <!-- Consulta de preguntas -->
       <table bgcolor="#ea8a00" width="490" height="170">
   <tr>
    <td>
    <table bgcolor="#FFFFFF" border="1" align="center" style="border:ridge">
    <tr class="encabezado">
    <th>
    Pregunta
    </th>
    <th>
    Seleccione las preguntas
    </th>   
    </tr>
     <?  while($MostrarFila2=mysql_fetch_array($Sql2)){  
		$SwVerificacion=1;?>
        <tr class="consulta1" onMouseOver="this.className='consulta2'" onMouseOut="this.className='consulta1'">
        <td>
        <? echo $MostrarFila2['Pregunta']; ?>
        </td>
        <td >
        <? if($MostrarFila2['id_eval']==0){ ?>
        <input name="pregunta" type="checkbox" onClick="validarCheck(this);" <? echo"value='".$MostrarFila2['id']."'";?> >
        <? }
		else{
			echo "Ya tiene evaluación";
		}
		?>
		 </td>
        </tr>
        <? } ?>
        <tr>
        <td colspan="9" align="center">
        <? 
		$total=$Preg->PaginarPreguntas();
		echo paginar($pag, $total, $tampag, "IngresarEvaluacion.php?pag="); ?>
        </td>
        </tr>
    </table>
    </td>
    </tr>
    </table>
        </td>
        </tr>
        <tr>
        <tr>
        <td width="113" align="center" bgcolor="#ea8a00">
<input type="submit" name="IngresarEvaluacion" value="Ingresar" onClick="return chequeaFormulario();" style="background-color:#999; font-weight:bold; font-size:10px;  border-left:solid #333; border-top:solid #333; border-bottom:ridge #CCC;-moz-border-radius: 15px; width:100px; cursor:pointer;">
 </td>
   </tr>
    </table>
    </form>
    </td>
    </tr>
    </table>
    <table width="490" cellpadding="0" cellspacing="0">
  <tr>
  <td colspan="2" height="9" bgcolor="#26354d">
  </td>
  </tr>
  <tr>
  <td colspan="2" height="9" bgcolor="#806600">
  </td>
  </tr>
  </table>
    
  </div>
  </div>
    </td>

	</tr>
	<tr>
	<td>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
  <div style="background-image:url(../imagenes/UsuarioProfesoresperemosqueestesi_03.gif); width:900px; height:63px;">
  
  </div>
    </td>
	</tr>
</table>
<!-- End Save for Web Slices -->
</body>
</html> 
bueno como se puede observar yo llamo al script ajax.js y la funcion es ValidarTema el me la reconoce pero no me hace nada que podrá ser de antemano muchas gracias!!
  #2 (permalink)  
Antiguo 14/07/2009, 16:40
 
Fecha de Ingreso: julio-2009
Mensajes: 81
Antigüedad: 14 años, 10 meses
Puntos: 6
Respuesta: Problema al llamar una funcion ajax

nunca he hecho algo asi... ademas tienes mas de dos tags de <script language="JavaScript">....
prueba "sacando" la funcion ValidarTema de "ajax.js"... y la metes dentro del primer <script language="JavaScript"> por si es problema de la funcion...

otra cosa que puedes hacer es meter todas las funciones que tienes en tus tags de <script language="JavaScript"> dentro del archivo js.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:00.