Foros del Web » Programando para Internet » Jquery »

Cargar Contenido ajax jquery metodo post

Estas en el tema de Cargar Contenido ajax jquery metodo post en el foro de Jquery en Foros del Web. Hola que tal a todos tengo un problema lo que sucede es que quiero cargar div y enviar parametros asi como tambien mostrar un mensaje ...
  #1 (permalink)  
Antiguo 21/06/2010, 11:46
 
Fecha de Ingreso: mayo-2010
Mensajes: 3
Antigüedad: 13 años, 10 meses
Puntos: 0
Busqueda Cargar Contenido ajax jquery metodo post

Hola que tal a todos tengo un problema lo que sucede es que quiero cargar div y enviar parametros asi como tambien mostrar un mensaje de cargando hasta ahora e logrado que envie parametros que cargue un div el mensaje se mantiene no desaparece pero lo mas importante cuando quiero cargar 2 div no me lo permite

index.php



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Enviar POST y GET con ajax</title>
<style>
.divmensaje {
position:absolute;
top: 50%;
left: 50%;
margin-left: -50px;
margin-top: -50px;
border:0px solid #1c5889;
background-color:#0000000;
color:#333;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:14px;
width:auto;
height:auto;
/*display:none;*/
}
</style>
* jQuery JavaScript Library v1.4.2
* http://jquery.com/
<script type="text/javascript" language="javascript" src="jquery.js"></script>

<script type="text/javascript" language="javascript" >
function toggle(what) {
var aobj = document.getElementById(what);
if( aobj.style.display == 'none' ) {
aobj.style.display = '';
} else {
aobj.style.display = 'none';
}
}
function CrearXMLHttp(){
XMLHTTP=false;
if(window.XMLHttpRequest){
return new XMLHttpRequest();
}else if(window.ActiveXObject){
return new ActiveXObject("Microsoft.XMLHTTP");
}
}
// suponiendo que tu div se llama loading
function OpenPage(url,id,loading,variables,metodo){
//alert(url+' '+id);
req=CrearXMLHttp();
if(req){
req.onreadystatechange = function() { manejador(id,loading); }; // aca cambie
if(metodo == 'post'){
req.open("post",url,true);
req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
req.send(variables);
}else{
req.open("get",url+'?'+variables,true);
req.send(null);
}
toggle(loading); // ojo aqui
}
}
function manejador(id,loading){
if(req.readyState == 4){
if(req.status == 200){
toggle(loading); // ojo aca
document.getElementById(id).innerHTML=req.response Text;
}else{
//alert("Error"+req.statusText)
alert("Error: es posible que tu navegador no sea compatible con las funciones de esta pagina, proba ingresando de nuevo desde Internet Explorer.");
}
}
}

function CargaContenido(contenedor,metodo,url,variables){

OpenPage(url,contenedor,'divmensaje',variables,met odo);
}
</script>

</head>

<body onload="divmensaje.style.display='';">

<div id="divmensaje" style="background-color:#FFFFFF; width:80px; color:#FFFFFF; font-weight:bold; display:none;"><img src="load.gif" />Cargando..</div>

<script>
CargaContenido('contenedor0','post','formulario.ph p','');
CargaContenido('contenedor2','get','recibe2.php',' txt3=10');
</script>
<div class="divmensaje" id="divmensaje"><center><img src='load.gif' border='0'>Procesando Solicitud..</center></div>

<div id="contenedor0">

</div>
<div id="contenedor1">


</div>
<div id="contenedor2">


</div>


</body>
</html>


formulario.php

<form id="form" name="form">
<input type="text" id="txt1" name="txt1" />
<input type="text" id="txt2" name="txt2" />

<input name="btn_form" type="button" value="Enviar Formulario" onclick="CargaContenido('contenedor1','post','reci be.php',''+$('form').serialize()+'');" />
<input name="btn_campo" type="button" value="Enviar Un campo" onclick="CargaContenido('contenedor1','post','reci be.php','&txt1='+$('form#txt1')+'');" /><br /><br />
<input name="btn_parametro" type="button" value="Enviar Un dos" onclick="CargaContenido('contenedor1','get','recib e.php','txt1=2&txt2=4');" /><br /><br />
</form>
<script>CargaContenido('contenedor2','get','recibe 2.php','txt3=30');</script>

recibe.php

Variable 1: <? echo $_REQUEST['txt1']; ?><br />
Variable 2:<? echo $_REQUEST['txt2']; ?><br />

<br />
URL:
<span class="Estilo1"><? echo $_SERVER['REQUEST_URI']; ?></span>

recibe2.php

<?
echo $_REQUEST['txt3'];
?>

Inicialmente en contenedor 2 debe salir 10 y en contenedor 0 debe salir el formulario al darle click al enviar formulario debe salir lo que ingrese en contenedor1 y contenedor2 debe mostrar 30 si alguien me puede ayudar muchas gracias a y el boton que dice enviar un campo del formulario no envia como puedo hacer eso tb muchas gracias
  #2 (permalink)  
Antiguo 23/11/2010, 23:48
Avatar de razengan  
Fecha de Ingreso: agosto-2007
Ubicación: Lima - Perulandia
Mensajes: 117
Antigüedad: 16 años, 8 meses
Puntos: 2
Respuesta: Cargar Contenido ajax jquery metodo post

realiza preguntas puntuales, no copies todos tus archivos aqui, te quiero ayudar pero me da un pereza leer todo ese codigo ademas tu pregunta no es del todo clara

Etiquetas: ajax, enviar, metodo, parametros, post_get, formulario
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 00:21.