Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/06/2013, 17:47
Avatar de Deathmetalrules
Deathmetalrules
 
Fecha de Ingreso: diciembre-2010
Ubicación: Mas - aya
Mensajes: 65
Antigüedad: 13 años, 5 meses
Puntos: 8
PHP + MYSQL+MVC me da un error en envio Jquery

buenas tardes amigos de foros del web...

la verdad soy nuevo en MVC ,bueno tengo algunos problemas con un jquery en mi codigo php, el caso es que estoy tratando de hacer un combo dependiente todo va bien hasta que selecciono una provincia y al cargar el combo de la ciudad envia "undefined"

gracias de antemano


aca el modelo :

Código PHP:
public function provincia(){
    
$this->conectar();
          
$this->data=array();
          
$this->query$this->consulta("SELECT *  FROM  provincia ORDER BY  nombreprovincia ASC ");
          if(
$this->numero_de_filas($this->query) > 0) {
          while ( 
$this->row $this->fetch_array($this->query) ) 
          
$this->data[] = $this->row;            
          return 
$this->data;
        }
    
    }    
public function 
ciudad($Id){
          
$this->conectar();
          
$this->datos=array();
          
$this->query$this->consulta("SELECT * FROM ciudad WHERE  ciudad='$Id' ORDER BY Idciudad ASC ");
          if(
$this->numero_de_filas($this->query) > 0) {
          while ( 
$this->row $this->fetch_array($this->query) ) 
          
$this->datos[] = $this->row;         
          return 
$this->datos;
         }
    
    } 
el controlador

Código PHP:

public function principal(){
      
        
$consulta =new auth;
        
ob_start();
                
        
$pagina=$this->load_template('Agregar');
        
$deprt=$consulta->getprovinica();
        
        
$Id=isset($_POST['d'])? $_POST['d'] : 1;
        
$ciudad $consulta->getciudad($Id);
             
$html= require("vista/centro.php");
        
$table ob_get_clean();
            
        
$pagina $this->replace_content('/\#CONTENIDO\#/ms',$table$pagina);
        
$this->view_page($pagina);
        } 
aca la vista:


Código PHP:
echo '<tr><td class="termina">Provincia:</td>';
        echo 
'<td><select name="provincia" id="provincia">';
        echo 
'<option value="0">-Seleccione Provincia-</option>';
        foreach(
$deprt as $i)
        {
        echo 
'<option value="'.$i[0].'">'.$i[1].'</option>';        
        }    
        echo
'</select></td>';
        
        
        echo 
'<td class="termina">Ciudad:</td>';
        
        echo 
'<td><select name="ciudad" id="ciudad">';
        
        echo
'</select></td></tr>'

y al final el jquery


Código PHP:
$(document).ready(function() {
            $(
"#provincia").change(function() {
                $(
"#provincia option:selected").each(function() {
                    var 
= $(this).val();
                    $.
ajax({
                      
type'POST',
                      
url'index.php?com=centro&action=principal',
                      
data'd='+d,
                      
success: function(data){
                    for ( var 
i=0;i<=data.length;i++)
                     {
                       $(
"#ciudad").append('<option value="' d[i].Idciudad '">' d[i].nombreciudad '</option>');
                        }
                         return 
false;
                      }
                     
                    });
                    });
            })
        }); 

gracias
__________________
Un nuevo horizonte