CodeIgniter Forums

Full Version: Function call not working in codeigneter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Unknown[/eluser]
Hi.

i'am trying to use function call in cjax. but is not work.

and this my source :
application/administrator/example.php

Code:
class example extends CI_Controller {
    function __constructs() {
         parent::__construct();
            
         require_once FCPATH.'ajaxfw.php';
    }

    function view() {
        $ajax = ajax();

         $ajax->click("button1",$ajax->call("ajax.php?recursive_ajax/call/0/30"));

         $data['page']       = 'administrator_content/ex';
         $this->load->view('container_administrator',$data);
    }
}

and this in response/recursive_ajax.php

Code:
class recursive_ajax {
    function call($counter, $count)
    {
        $counter = (int) $counter;
        $count = (int) $count;

        $counter++;

        $ajax = ajax();

        if($count > 100) {
                $ajax->focus('count');
                $ajax->warning("Too many requests can add overhead to our servers, please try reducing the number.", 5);
                $ajax->count = 30;
                return;
        }

        //update div
        $ajax->div_counter = "Call# $counter of $count..";

        if($counter>=$count) {
                $ajax->div_counter ="$counter recursive AJAX requests were made.";
        } else {

                //fire call
                $ajax->call("ajax.php?recursive_ajax/call/$counter/$count");
        }

    }

}

and this views/administrator_content/ex.php

Code:
<HTML>
<head>
    <title>Example</title>
    <!-- include cjax-5.6.js -->
</head>
<body>
<input type='button' id='button1' value ='Start recursive requests'/>
<div id='div_counter'></div>
&lt;/body&gt;

&lt;/HTML&gt;

please what wrong in my code? Big Grin

El Forum

[eluser]CroNiX[/eluser]
Code:
$ajax->click("button1",$ajax->call("ajax.php?recursive_ajax/call/0/30"));
Try using a full url here in your ajax::call() instead of relative.

El Forum

[eluser]Unknown[/eluser]
thank for your reply. the problem corrected with by changing the :

Code:
$ajax->click("button1",$ajax->call("ajax.php?recursive_ajax/call/0/30"));

with

Code:
$ajax->click("button1",$ajax->call("../../ajax.php?recursive_ajax/call/0/30"));

Big Grin