Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/11/2014, 09:04
domichis
 
Fecha de Ingreso: julio-2014
Mensajes: 59
Antigüedad: 10 años, 6 meses
Puntos: 0
Consulta desde Ajax

Este es mi codigo HTML
(Formulario)

Código HTML:
</script>
<form method='GET' action='/get_city_state.php'>
  <input type='text' name='zip' size='20'></p>
  <p><input type='text' name='city' size='20'></p>
  <p><input type='text' name='state_abbr' size='20'></p>
  <p><input type='submit' value='Enviar' name='B1'></p>
</form> 
Aqui esta mi codigo Ajax
(Codigo que hace las llamadas)

Código PHP:
<script>
var 
ajax getHTTPObject();

function 
getHTTPObject()
{
    var 
xmlhttp;
    if (
window.XMLHttpRequest) {
      
// code for IE7+, Firefox, Chrome, Opera, Safari
      
xmlhttp=new XMLHttpRequest();
    } else if (
window.ActiveXObject) {
      
// code for IE6, IE5
      
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    } else {
      
//alert("Your browser does not support XMLHTTP!");
    
}
    return 
xmlhttp;
}

function 
updateCityState()
{
    if (
ajax)
    {
        var 
zipValue document.getElementById("zipcode").value;
        if(
zipValue)
        {
            var 
url "/get_city_state.php";
            var 
param "?zip=" escape(zipValue);

            
ajax.open("GET"url paramtrue);
            
ajax.onreadystatechange handleAjax;
            
ajax.send(null);
        }
    }
}
function 
handleAjax()
{
    if (
ajax.readyState == 4)
    {
        
citystatearr ajax.responseText.split(",");

        var 
city document.getElementById('city');
        var 
state document.getElementById('state');

        
city.value citystatearr[0];
        
state.value citystatearr[1];
    }
}
</script> 

Que le debo agregar a mi formulario para que realice las llamadas Ajax

En estos campo que debo de agregar.

Código:
  <input type='text' name='zip' size='20'>
  <input type='text' name='city' size='20'>
  <input type='text' name='state_abbr' size='20'>
  <input type='submit' value='Enviar' name='B1'>
Saludos