Cita:
Iniciado por Franz1628
amigo mejor prueba con esto a ver
Código HTML:
Ver original<!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"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> function requerir(){
try{
req=new XMLHttpRequest();
}catch(err1){
try{
req=new ActiveXObject("Microsoft.XMLHTTP");
}catch(err2){
try{
req=new ActiveXObject("Msxml2.XMLHTTP");
}catch(err3){
req= false;
}
}
}
return req;
}
var peticion=requerir();
function llamarAjax(){
var aleatorio=parseInt(Math.random()*999999999);
var campo=document.form1.apellido.value;
var campo2=document.form1.nombre.value;
var url="codigo.php?var="+campo+"&r="+aleatorio+"&c2="+campo2;
peticion.open("GET",url,true);
peticion.onreadystatechange =respuestaAjax;
peticion.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
peticion.send(null);
}
function respuestaAjax(){
if(peticion.readyState==4)
{
if(peticion.status==200)
{
var miPeticion = JSON.parse(peticion.response);
document.getElementById("dina").innerHTML=miPeticion.var;
document.getElementById("apellidoDiv").innerHTML=miPeticion.c2;
}
else
{
alert("ha ocurrido un error"+peticion.statusText);
}
}
else
{
document.getElementById("dina").innerHTML='
<img src="carga.gif" />';
}
}
<form action="" method="post" enctype="application/x-www-form-urlencoded" name="form1" id="form1"> <input type="text" name="nombre" id="nombre" /> <div id="dina"></div><!--aqui quiero traer de la pagina solo la variable $_GET['var']; --> <input type="text" name="apellido" id="apellido" /> <div id="apellidoDiv"></div> <!--aqui quiero traer de la pagina solo la variable $_GET['c2'];-->
<input name="" type="button" onclick="llamarAjax()" />
codigo.php
Código PHP:
Ver original<?php
$array['var'] = $_GET['var'];
$array['c2'] = $_GET['c2'];
?>
que hermoso es lo que me enseñaste
mil gracias y que Dios te bendiga
realmente eres un master