Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1563 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  Codeigniter & ajax : The script tried to execute a method or access a

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Codeigniter & ajax : The script tried to execute a method or access a

n°1933845
allserv
Posté le 20-10-2009 à 16:39:18  profilanswer
 

Bonjour,
 
 
Je développe un site web sous le framework CodeIgniter. Je suis actuellement bloqué avec un problème lors de l'enregistrement des mes obejts contenus dans mon panier.
 
L'erreur survient lorsque j'ajoute un objet à l'aide d'une requête http en asyncrhone (ajax), la méthode en question est la suivante :
 

Code :
  1. <?php
  2.     function addNdd(){
  3.        
  4.         $ndd = $this->input->post('ndd');       
  5.         $extension = $this->input->post('extension');   
  6.         $etat = $this->input->post('etat');   
  7.        
  8.        
  9.         $this->load->library('cart');
  10.         $cart =& Cart::getInstance();
  11.        
  12.         $type = ($etat==1) ? "commande":"transfert";
  13.        
  14.        
  15.         $o = FabriqueItem::create('ndd',array('ndd'=>$ndd.'.'.$extension,'tps'=>12,'type'=>$type));
  16.         $prix = $this->devise->getAmount($this->mdl_domaine->getPrix($extension));
  17.        
  18.        
  19.         $result = ($cart->addArticle($o));
  20.         if($result){   
  21.             $xml = '<racine><resultat reponse="addNdd" ndd="'.$ndd.'.'.$extension.'" prix="'.$prix.'">true</resultat><description>'.$o->getNdd()." ".$o->getType()." - ".$this->devise->getPrice($o->getPrix()).' - '.$o->getTps().' mois</description></racine>';
  22.            
  23.         } else
  24.         $xml = '<resultat reponse="addNdd">false</resultat>';
  25.    
  26.            
  27.         $data['xml'] = utf8_encode($xml);
  28.        
  29.         log_message('debug', $xml);
  30.        
  31.        
  32.         $this->load->view('ajax/display',$data);       
  33.        
  34.     }?>


 
Il s'avère que lorsque je n'utilise pas l'ajout via cette page, l'insertion en base de données se fait correctement. C'est comme si la création de l'objet n'était aps fait correctement puisque j'ai une erreur du type :
 

Citation :

   A PHP Error was encountered
 
    Severity: Notice
 
    Message: ItemNdd::save() [function.ItemNdd-save]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition “Ajax” of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition
 
    Filename: libraries/Cart.php
 
    Line Number: 331


 
La méthode save est la suivante :
 

Code :
  1. <?php
  2. class ItemNdd extends Item {
  3.    
  4.     var $ndd='';
  5.     var $type='';
  6.    
  7.     function ItemNdd($ndd,$tps,$type){
  8.             parent::Item($tps);
  9.             $this->ndd = $ndd;       
  10.             $this->type = $type;    // achat ou transfert
  11.             $this->prix = $this->CI->mdl_domaine->getPrix($this->CI->mdl_domaine->getExtension($this->ndd));
  12.     }
  13.    
  14.     function getNdd(){
  15.         return $this->ndd;
  16.     }
  17.    
  18.     function equals($object){
  19.         if(!($object instanceof ItemNdd)) return false;
  20.         if($this->ndd==$object->ndd) return true;
  21.        
  22.         return false;
  23.     }
  24.    
  25.     function toString(){
  26.        
  27.         return "<br>Nom de domaine : ".$this->ndd.
  28.         "<br> Durée : ".$this->getTps()." mois <br>Prix :".$this->prix;
  29.        
  30.     }
  31.    
  32.     function save($id_commande){
  33.        
  34.         $data = array(
  35.                     'id_item'=>'',
  36.                     'id_commande'=>$id_commande,
  37.                     'type'=>'ndd',
  38.                     'titre'=>$this->type.' nom de domaine : '.$this->ndd,
  39.                     'nbre_mois'=>parent::getTps(),
  40.                     'prix'=>$this->CI->devise->getAmount($this->prix),                   
  41.                     'date'=>date('Y-m-d H:i:s'));
  42.        
  43.        
  44.         $this->CI->db->insert('items',$data);
  45.     }
  46. }?>


 
Si quelqu'un aurait une piste à suivre.
 
 
Merci d'avance
 
Louis

mood
Publicité
Posté le 20-10-2009 à 16:39:18  profilanswer
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  Codeigniter & ajax : The script tried to execute a method or access a

 

Sujets relatifs
Diminuer taille du texte dans un scriptListe deroulante restreinte dans une table [ACCESS]
Script Batch téléchargement httpScript VB pour ré-installation d'imprimantes [aide svp]
Programmation script shell ksh unixPrendre la valeur après un ping
aide script PHP/SQLITE[Javascript] Aide pour adapter un script - [Résolu]
[AJAX] onreadystatechange non reconnumodification script php/mysql
Plus de sujets relatifs à : Codeigniter & ajax : The script tried to execute a method or access a


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR