Welcome Guest, Not a member yet? Register   Sign In
Xajax: Undefined index: query, can't return data to browser!
#1

[eluser]Juicie[/eluser]
I have the following code:

Code:
function add_guestbook($data)
    {
        if($this->model->Add_guestbook_entry($data))
        {
        $message='<div class="notice">Message added successfully!</div>';
        }
        else
        {
        $message='<div class="error">Adding message failed!</div>';
        }
        
        $add_guestbook_response = new xajaxResponse();

        $add_guestbook_response->assign("message_div", "innerHTML", $message);
        $add_guestbook_response->assign("name", "value", "");
        $add_guestbook_response->assign("email", "value", "");
        $add_guestbook_response->assign("message", "value", "");

        return $add_guestbook_response;
    }

I've used XAJAX before and didn't encounter any problems. But for a new site i'm running into a problem. I have this code executed by a submit button. It get's the data from a form a puts the data into the database. That works fine. Now I wan't sen't a message back containing a confirmation or error message. And I want to empty the form whitout reloading the page. The last two parts don't work.
I'm seeing the following notice in the error log:
Severity: Notice --&gt; Undefined index: query /usr/home/********/domains/******.**/public_html/website/system/libraries/xajax.php 907

Has it something to de with me using ob_start(); at the first codeignitor index.php file?

Can't find the solution, have searched this forum and XAJAX forum.

Regards
#2

[eluser]jgodino[/eluser]
I have the same error.

Severity: Notice --&gt; Undefined index: query /home/jgodino/public_html/xxxx/sginfra_system_files/application/libraries/xajax.php 572

Regards

Javier
#3

[eluser]CopyJosh[/eluser]
I've been having this problem now too.. starting to look for a fix. any solutions?
#4

[eluser]InsiteFX[/eluser]
See the code below, the problem is that the first line will only work for the default controller!
For all other controllers you need to use the second line.
Code:
// --------------------------------------------------------------------

/**
* __construct()
*
* Class    Constuctor PHP 5+
*
* @access    public
* @return    void
*/
public function __construct()
{
    parent::__construct();
        
    // Initialize xajax
    $this->_xajax();
}

// --------------------------------------------------------------------

/**
* _xajax()
*
* Load, intialize and configure the xajax library.
*
* @access    private
* @return    void
*/
private function _xajax()
{
    $this->load->library('xajax');

    // this is the problem here in the configure!
    // this line will only work for the default controller!
    $this->xajax->configure("requestURI", base_url());

    // for all other controllers you need to do this!
    $this->xajax->configure("requestURI", site_url('Controller'));

    $this->xajax->configure("javascript URI", base_url().'assets/');

    // Register xajax PHP functions
    $this->xajax->register(XAJAX_FUNCTION, array('method_name', &$this, 'method_name'));

    $this->xajax->processRequest();
}
Curiosity of IgnitedCoder.

InsiteFX
#5

[eluser]CopyJosh[/eluser]
InsiteFX, that is a good way of distinguishing, but it honestly doesn't matter if you use either one as long as you point to the controller that makes the call, for example, you can also use:

Code:
$this->xajax->configure("requestURI", base_url('index.php/controller'));

For some reason mine is working for simple ajax function calls (i.e. change the innerHTML of a div via <a >) but it still gives me the query error

Code:
Severity: Notice  --&gt; Undefined index: query C:\Program Files (x86)\EasyPHP-5.3.6.0\www\CodeIgniter\application\libraries\xajax\Xajax.php 1010
#6

[eluser]Unknown[/eluser]
Thank you InsiteFX now Xajax is working Smile




Theme © iAndrew 2016 - Forum software by © MyBB