EllisLab text mark
Advanced Search
     
HELP ME!!! XAJAX DOES NOT WORK
Posted: 16 July 2007 09:57 AM
Joined: 2007-07-09
7 posts

this is the debug of xajax, When I use one of my model’function’s I receive this error. Help me please.

Xajax debug output

Mon Jul 16 2007 14:54:59 GMT+0200: Received: <div solid #990000;padding-left:20px;margin:0 0 10px 0;”>

A PHP Error was encountered

Severity: Notice Message: Undefined property: Ajaxtest::$officina_app_model Filename: controllers/ajaxtest.php Line Number: 32 </div>
Mon Jul 16 2007 14:54:59 GMT+0200: Calling test_function uri=http://localhost/CodeIgniter/index.php/ajaxtest (post:xajax=test_function&xajaxr=1184590499631&xajaxargs;[]=3)
Mon Jul 16 2007 14:54:59 GMT+0200: Initializing Request Object..
Mon Jul 16 2007 14:54:59 GMT+0200: Starting xajax…

 Signature 

ohh

 
Posted: 16 July 2007 10:37 AM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2006-06-23
370 posts

Please don’t use ALL CAPS. Now let’s see if we can figure this out.

The problem is on line 32 of your Ajaxtest controller, in the test_function() method. You’re attempting to access a property called “afficina_app_model”, but it’s not loaded. Is the model loaded properly?

Can you please post the code of that method so we can see what you’re attempting to do?

 Signature 

Mac OS X 10.8, Apache 2.x, NGiNX, PHP 5.4.x, CodeIgniter 1.7.2/2.1.3

 
Posted: 16 July 2007 11:08 AM   [ # 2 ]   [ Rating: 0 ]
Joined: 2007-07-09
7 posts

I resolved All.

In the controller I have:

function Ajaxtest()
  {
parent::Controller();

//load the helper url
$this->load->helper('url');

//to load my model
$this->load->model("mymodel"); // Moved up 2 lines

//load xajax library
$this->load->library('xajax');

//$this->xajax->debugOn();

//to record my xajax function
$this->xajax->registerFunction(array('test_function',&$this,'test_function'));

//execute process requests
$this->xajax->processRequests();



//carico la libreria per la creazione di template
$this->load->library('parser');

}
In the function xajax:

function test_function($Scaffale)
    {

$statoRipiani = $this->mymodel->getStatoRipiani();
$objResponse = new xajaxResponse();
$objResponse->addAssign("SomeElementId","innerHTML", "Scaffale passato:".$this->getTabRipiani());

return $objResponse->getXML();
}

In above xajax function I call $this->mymodel->getStatoRipiani() that it has this code:

function getTabRipiani()
  {
$tabRipiani = '<table align = "center">';

$StatoRipiani = $this->mymodel->getStatoRipiani();

for($i = 0; $i < count($StatoRipiani); $i++)
{
$tabRipiani .= "<tr>
<td>";
if($StatoRipiani[$i] == 2)
$tabRipiani .= "\"".base_url()."system/application/immagini/scaffali_ripiani/Ripiani/pieno_ripiano.png\" width=\"100%\" height=\"20\" align =\"top left\"/";
else if($StatoRipiani[$i] == 1)
$tabRipiani .= "\"".base_url()."system/application/immagini/scaffali_ripiani/Ripiani/mezzo_ripiano.png\" width=\"100%\" height=\"20\" align =\"top left\"/ ";
else
$tabRipiani .= "\"".base_url()."system/application/immagini/scaffali_ripiani/Ripiani/vuoto_ripiano.png\" width=\"100%\" height=\"20\" align =\"top left\"/ ";

$tabRipiani .= " </td>
</tr>";
}
     
      $tabRipiani .= “</table>”;
     
      return $tabRipiani;

  }

in above function I use base_url() function. This funtion belongs in codeigniter helper url.

The helper or another library of codeigniter must be called first you call   $this->xajax->processRequests(); becouse xajax not know what is base_url() function.

I hope you have understand becouse I don’t speak very well english.

thank you all for your posts.

 Signature 

ohh

 
Posted: 16 July 2007 11:17 AM   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2006-06-23
370 posts

Try to put [ code ] tags around your code samples to make it easier to read. You can use “Code” button when editing your post.

Glad you got it fixed. It appears the model wasn’t being loaded soon enough.

 Signature 

Mac OS X 10.8, Apache 2.x, NGiNX, PHP 5.4.x, CodeIgniter 1.7.2/2.1.3

 
Posted: 16 July 2007 12:52 PM   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2006-10-03
31 posts

you’re a genius coolfactor smile))))

 Signature 

Stupid people do stupid things, smart people outsmart each otherSOAD