CodeIgniter Forums

Full Version: HELP ME!!! XAJAX DOES NOT WORK
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Paganotti[/eluser]
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 style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"> <h4>A PHP Error was encountered</h4> <p>Severity: Notice</p> <p>Message: Undefined property: Ajaxtest::$officina_app_model</p> <p>Filename: controllers/ajaxtest.php</p> <p>Line Number: 32</p> </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...

El Forum

[eluser]coolfactor[/eluser]
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?

El Forum

[eluser]Paganotti[/eluser]
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 .= "<img src=\"".base_url()."system/application/immagini/scaffali_ripiani/Ripiani/pieno_ripiano.png\" width=\"100%\" height=\"20\" align =\"top left\"/>";
else if($StatoRipiani[$i] == 1)
$tabRipiani .= "<img src=\"".base_url()."system/application/immagini/scaffali_ripiani/Ripiani/mezzo_ripiano.png\" width=\"100%\" height=\"20\" align =\"top left\"/> ";
else
$tabRipiani .= "<img src=\"".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.

<strong>The helper or another library of codeigniter must be called first you call $this->xajax->processRequests();</strong> 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.

El Forum

[eluser]coolfactor[/eluser]
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.

El Forum

[eluser]Skulls[/eluser]
you're a genius coolfactor Smile))))