Welcome Guest, Not a member yet? Register   Sign In
Ajax Framework (CJAX) for Codeigniter 2.x+
#91

[eluser]MonsterTKE[/eluser]
[quote author="Ajaxboy" date="1340616947"]It is recommended to use firebug (https://getfirebug.com/) for quick error debugging, it appears the path for the js lib is incorrect,So the js lib is not being loaded.

[/quote]

I had included the script in the head tag as was mentioned in a different post.

If I include <?php echo $ajax->init();?> in the head tag it errors out. It shows the script as loaded but it errors with "Call to undefined function ajax() in /var/www/application/views/templates/header.php on line 1"
#92

[eluser]Ajaxboy[/eluser]
The place where it was it is fine. but the path was wrong..

try this:

Leave it where it was, but do it like this:

Code:
<?php echo $ajax->init('http://monstertke.zapto.org/');?>

As mentioned in the documentation: http://cjax.sourceforge.net/docs/Iniciat...Engine.php
#93

[eluser]MonsterTKE[/eluser]
Code:
<$cript defer='defer' id='cjax_lib' type='text/javascript' src='cjax/core/js/cjax-5.0-RC2.min.js'>[removed]

In the head tag works fine... for the front page only.

Code:
<$cript id='cjax_lib' type='text/javascript' src='cjax/core/js/cjax-5.0-RC2.min.js'>[removed]


s changed to $ so it would let me post.

As mentioned in the documentation throws an ajax error. "process unable to load function"

the $ajax->init(http://monstertke.zapto.org/); Just throws a "Call to undefined function ajax()"

Code:
&lt;?php $ajax = ajax(); echo $ajax->init(http://monstertke.zapto.org/); ?&gt;
#94

[eluser]Ajaxboy[/eluser]
Make sure you add quotes in the url: 'http://monstertke.zapto.org/'
#95

[eluser]MonsterTKE[/eluser]
[quote author="Ajaxboy" date="1340619765"]Make sure you add quotes in the url: 'http://monstertke.zapto.org/' [/quote]

Sorry for the issues Ajaxboy but its still not working.
"vendors/index"
Code:
public function index() {
  $this->load->file(FCPATH.'ajaxfw.php');
  $this->load->model('Vendor_model');

  $config['base_url'] = 'http://monstertke.zapto.org/vendors/index/';
  $config['total_rows'] = $this->db->get('vendors')->num_rows;
  $config['per_page'] = 5;

  $this->pagination->initialize($config);

  $pagination_default = 0;

  if(is_numeric($this->uri->segment(3))) {
   $pagination_default = $this->uri->segment(3);
  }

  $data['page_title'] = "Vapelist (working title)";
  $data['result'] = $this->Vendor_model->get_all_vendors($pagination_default);
  $data['session_info_ip'] = $this->session->userdata('ip_address');
  $data['session_info_agent'] = $this->session->userdata('user_agent');

  $ajax = ajax();

  foreach ($data['result'] as $row) {
   $ajax->Exec("ajax_vote_call_down_{$row->id}", $ajax->overlay("/ajax/votes_comment/vote/{$row->id}/down"));
            $ajax->Exec("ajax_vote_call_up_{$row->id}", $ajax->overlay("/ajax/votes_comment/vote/{$row->id}/up"));
  }


  $this->load->view('templates/header', $data);
  $this->load->view('templates/navigation', $data);
  $this->load->view('vendors/vendor', $data);
  $this->load->view('templates/footer');

  $this->output->enable_profiler(TRUE);
  }
view "vendors/vendor"
Code:
&lt;?php $this->load->helper('text');?&gt;
<div id="body_wrapper">
&lt;?php foreach ($result as $row):?&gt;  
        <div class="listing_wrapper">
        <div class="inner_listing_wrapper">
        <div id ="vendor_juice"><h2><a href="&lt;?php echo base_url(); echo">id?&gt;">&lt;?php echo $row->name?&gt;</a></h2></div>  
        <div id ="vendor_name"><p><a href="&lt;?php echo $row-&gt;url_link?&gt;">&lt;?php echo $row->vendor_name?&gt;</a></p></div>
        <div id ="vendor_desc"><p>&lt;?php
                                        $url_string = base_url();
                                        $read_more = "   ...<a >id}>\"read more\"</a>";
                                        echo word_limiter($row->description, 20, $read_more);?&gt;</p></div>
        <div id ="vendor_catg">&lt;?php echo $row->category?&gt;</div>
                <div class ="vendor_votes">
                        <div class="vote_box_u"><h3><a href="#">id}";?&gt; title="Vote '&lt;?php echo $row-&gt;name?&gt;' up.">&lt;?php echo $row->votes_up?&gt;</a></h3></div>
                                        

                        <div class="vote_box_d"><h3><a href="#">id}";?&gt; title="Vote '&lt;?php echo $row-&gt;name?&gt;' down.">&lt;?php echo $row->votes_down?&gt;</a></h3></div>
          
                </div>                                          
        </div>
    </div>
        &lt;?php endforeach;?&gt;
        <div id='pagination_links'>&lt;?php echo $this->pagination->create_links();?&gt;</div>
</div>
Header view
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html xml:lang="en" lang="en"&gt;

&lt;head&gt;
&lt;title&gt;&lt;?php echo $page_title ?&gt;&lt;/title&gt;
&lt;meta http-equiv="content-type" content="text/html;charset=utf-8" /&gt;
&lt;link rel="stylesheet" href='&lt;?=base_url()?&gt;css/styles.css' type="text/css" media="screen, projection" /&gt;
&lt;link rel="stylesheet" href='&lt;?=base_url()?&gt;css/typography.css' type="text/css" media="screen, projection" /&gt;
&lt;link rel="stylesheet" href='&lt;?=base_url()?&gt;css/forms.css' type="text/css" media="screen, projection" /&gt;
&lt;link rel="stylesheet" href='&lt;?=base_url()?&gt;css/list_layout.css' type="text/css" media="screen, projection" /&gt;
&lt;link rel="stylesheet" type="text/css" href="&lt;?=base_url()?&gt;css/auth.css" /&gt;

&lt;?php $ajax = ajax(); echo $ajax->init("http://monstertke.zapto.org/"); ?&gt;
&lt;/head&gt;

&lt;html&gt;
&lt;body&gt;

And the ajax function it is supposed to call.
Code:
class votes_comment extends CI_controller {

    function vote($juice_id, $vote_direction) {

        $this->load->model('Vendor_model');
        $this->load->model('Rating_model');

        $data['page_title'] = 'Add rating';
        $data['user_data_id'] = $this->tank_auth->get_user_id();
        $data['user_data_logged'] = $this->tank_auth->is_logged_in();
        $user_name = $this->tank_auth->get_username();

        $data['vote_result'] = 'good deal';
        $data['ajax_message'] = '';
        $data['switch_var'] = 1;

        $juice_result = $this->Vendor_model->get_individual_juice('vendors', 'id', $juice_id);

        foreach($juice_result as $jd) {

            $data['v_id'] = $jd->id;
            $data['v_j_name'] = $jd->name;
            $data['v_v_name'] = $jd->vendor_name;
            $data['v_url'] = $jd->url_link;
            $data['v_image'] = $jd->url_image;
            $data['v_desc'] = $jd->description;
            $data['v_created'] = $jd->created;
            $data['v_modified'] = $jd->modified;
            $data['v_user'] = $jd->user_id;
            $data['v_category'] = $jd->category;
            $data['v_votes_up'] = $jd->votes_up;
            $data['v_votes_down'] = $jd->votes_down;
            $data['v_banned'] = $jd->banned;
        }


        $data['vote_increment_model'] = '';

        $data['vote_column'] = 'error';

        //    function can_vote($juice_id, $user_id
        if ($data['user_data_logged']) {
        $has_voted = $this->Rating_model->can_vote($juice_id, $data['user_data_id']);
     }
     else {
      redirect('/auth/login/');
     }
The rest was cut off.
#96

[eluser]MonsterTKE[/eluser]
&lt;?php $ajax = ajax(); echo $ajax->init("http://monstertke.zapto.org/"); ?&gt;

for that part, I have done it every way, single quotes, double quotes, no quotes "base_url() etc.
#97

[eluser]Ajaxboy[/eluser]
It works fine for me (shows the overlays, but not content). There is a 500 error, meaning there is an error in your php syntax within http://monstertke.zapto.org/auth/login

You might want to turn on error display in php or look at your apache error log. This is a php error in your php syntax.
#98

[eluser]Ajaxboy[/eluser]
There is another way to specify the url:

in file
Quote:cjax/config.default.php

find setting:
Code:
$config->init_url

then change it to:

Code:
$config->init_url = 'http://monstertke.zapto.org';

then rename the file 'config.default.php' to 'config.php', then you won't need to enter the url in
Code:
$ajax->init()
.
#99

[eluser]MonsterTKE[/eluser]
meh,

with the script source set manually in the head tag clicking one of the red/green links in the listings overlays the tank auth view like it is supposed to. So does clicking on "login"

The 500 error you were seeing was it spinning on "[client 76.203.***.***] PHP Fatal error: Call to undefined function ajax() in /var/www/application/views/templates/header.php on line 13"

Which is what it does whis the $ajax->init(url); part in place.

It is working fine and doing exactly what I want it to do except for not making the correct connections on the paginated results.:down:

Ill try explicitly setting the url in the config.

[eluser]MonsterTKE[/eluser]
[quote author="Ajaxboy" date="1340621366"]There is another way to specify the url:

in file
Quote:cjax/config.default.php

find setting:
Code:
$config->init_url

then change it to:

Code:
$config->init_url = 'http://monstertke.zapto.org';

then rename the file 'config.default.php' to 'config.php', then you won't need to enter the url in
Code:
$ajax->init()
.[/quote]

Damn.. Is there a way to autoload the ajax.php file?

Auth/login is trying to call the function due to the header template being loaded.





Theme © iAndrew 2016 - Forum software by © MyBB