ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Ajax Framework (CJAX) for Codeigniter 2.x+

April 29, 2012 11:33am

Subscribe [24]
  • #121 / Jul 02, 2012 11:17am

    rafabkn

    7 posts

    Running this:

    ‘http://localhost/test/ajax.php?sample/test/1/2/3’

    from this code:

    class controller_sample extends CI_Controller {
        
        function test($a,$b,$c)
        {
    
            //$c = new Country(); // This line from DataMapper is giving troubles with CJAX 
            
            $ajax = ajax();
            die('ajax:<pre>'.print_r($ajax,1).'<pre>');
    
    
            $ajax->update('content', "Esto es AJAX");
        }
    
    }

    gives this output:

    ajax:
    CJAX_FRAMEWORK Object
    (
        [config] => ext Object
            (
                [settings] => 
            )
    
        [strict] => 
        [message_id] => 
        [trace] => 0
        [xmlObjects:CoreEvents:private] => 
        [lastCmd] => 
        [selector] => 
        [loading] => 
        [fallback] => 
        [post] => Array
            (
            )
    
        [dir] => 
        [attach_event] => 1
        [log] => 
        [session_id] => 
        [port] => 80
        [controller_dir] => 
        [format] => cjaxFormat Object
            (
            )
    
        [caching] => 
        [crc32] => 
        [event] => onClick
        [text] => 
        [debug] => 
        [version] => 5.0-RC3
        [is_init] => 
        [method] => 
        [_path] => 
        [jsdir:CoreEvents:private] => cjax/core/js/
        [caller] => 
        [_flag] => 
        [_flag_count] => 0
    )
  • #122 / Jul 02, 2012 11:32am

    rafabkn

    7 posts

    If I uncomment the line:

    class controller_sample extends CI_Controller {
        
        function test($a,$b,$c)
        {
    
            $c = new Country(); // This line from DataMapper is giving troubles with CJAX 
            
            $ajax = ajax();
            die('ajax:<pre>'.print_r($ajax,1).'<pre>');
    
    
            $ajax->update('content', "Esto es AJAX");
        }
    
    }

    I get this server error:

    PHP Fatal error:  Call to undefined method CI_DB_mysql_driver::dm_call_method() in /var/www/html/test/application/libraries/datamapper.php on line 1024
  • #123 / Jul 02, 2012 12:53pm

    Ajaxboy

    243 posts

    @rafabkn

    Update:

    I did some testing, and got a similar error:

    ( ! ) Fatal error: Call to undefined method CI_DB_mysql_driver::dm_call_method() in application\libraries\datamapper.php on line 1113

    The error was there even when cjax wasn’t present, this is was not a conflict with cjax, it was an actual error from DataMapper.

    This error is unrelated to the Ajax Framework,  and has nothing todo with Cjax.

    I suggest maybe ask in DataMapper thread or to wanwizard to see if he can offer any insights.

    -cj

  • #124 / Jul 02, 2012 1:16pm

    rafabkn

    7 posts

    Thank you very much for your help.

    I will try in a different way for using AJAX and DataMapper.

    Thank you very much for your time.

  • #125 / Jul 02, 2012 3:49pm

    ysh

    4 posts

    hello Ajaxboy, thanks a lot for the library,...starting with the library.

  • #126 / Jul 05, 2012 5:40pm

    Simple Focus

    9 posts

    Hi, I was hoping someone that has used this framework successfully can help me troubleshoot an issue.

    I am trying to get CJAX to work and get 500 Internal Server errors with anything that uses the framework. This includes the default out-of-the-box request that the instruction page says should work http://www.domain.com/ajax.php?test/test, as well as any of the example files.

    I have tried the following on both a local server and a production server to rule out local problems:

    1. I downloaded the latest Codeigniter package (2.1.2) and got it successfully working.

    2. I installed the framework (5.0 Stable) as directed on the instructions page (basically just copied the files to the server). I have done nothing else to the Codeigniter installation. I tried both with no .htaccess file and renaming the htaccess.txt to .htaccess.

    Does anyone know what would cause the 500 errors? Was there something that I should have done to the default Codeigniter installation prior to attempting to install CJAX?

    Thanks for your help.

    Scotty Bollinger

  • #127 / Jul 05, 2012 5:59pm

    Simple Focus

    9 posts

    For anyone having the same issue, I got it working, thanks in part to help from ajaxboy. For details, see this post and the 2 underneath it.

  • #128 / Jul 06, 2012 1:44am

    MonsterTKE

    27 posts

    @Ajaxboy

    Is this library supposed to work on mobile devices?

    “process unable to load function#1: _overlay();
    Cannot set property ‘display’ of undefined”

    Is the error I get on android. I am currently loading in separate views for mobile user agents, but I was wondering if there is something Im missing here?

  • #129 / Jul 06, 2012 1:59am

    Ajaxboy

    243 posts

    @MonsterTKE,

    There have no been tests on mobile devices because there has been not demand for it, but we might start testing on mobile devices in the near future.

  • #130 / Jul 06, 2012 2:04am

    MonsterTKE

    27 posts

    @MonsterTKE,

    There have no been tests on mobile devices because there has been not demand for it, but we might start testing on mobile devices in the near future.

    Yeah, I totally understand, I just write my views without ajax, then I copy and rename them to mobile_whateverView then I add the Ajax stuff to the existing controller for the desktop site.

    It is a pain in the ass to debug mobile sites.

  • #131 / Jul 12, 2012 3:31am

    ev0ken

    4 posts

    Hey Great framework but I keeping getting a error my $subject_id is putting “css” instead of the id. $subject_id has the correct value set because if I echo it the returned value is the correct one I want but for some reason inside the $ajax->exec function its sending “css”. Sorry about my english i’ve been up all night

  • #132 / Jul 12, 2012 3:35am

    Ajaxboy

    243 posts

    Hello ev0ken,

    Could you please post your code that you are using?  thanks. Also be sure sure you are using the latest release (5.0-stable).

  • #133 / Jul 12, 2012 3:44am

    ev0ken

    4 posts

    Wont let me post code can i email you? Also yes i’m using the current version I downloaded it yesterday 😛

  • #134 / Jul 12, 2012 4:09am

    Ajaxboy

    243 posts

    I got the email.

    you have multiple php syntax errors in your code. Sorry but you have alot of things backwards in your code, I can try to help but you must posses at least general php knowledge to be able to use this ajax framework without much pain, I am not going to teach php.

    Here I fixed the syntax for you. Also your html element HAVE TO exist in the view.

    The ‘blad’ and ‘lol’ are in the parameter for element/div id in which the response is loaded to.

    You only need to do $ajax = ajax() once (per scope).


    there is some filtering going on and some of the code is being obfuscated/truncated, I’ll reply the code to your email.

    $ajax = ajax();
    
    ?>
    <div class = "subj-nav"> 
    <?php 
    if(isset($catg_data)) {
    
     foreach($catg_data as $catg) {
      ?><a href ='#' id = 'catg<?php echo $catg['><?php echo $catg['catg_name'];?></a><?php
     
     
      if($this->tank_auth->is_logged_in()){
       $logged_in = 1;} 
      else { 
       $logged_in =0;
      }
     
      $ajax->Exec('catg'.$catg['catg_id'],
     
      $ajax->call(base_url('ajax.php?post/get_prod/'.$catg['catg_id'].'/'.$logged _in), 'blad'));
     
     }
    
    } 
    if($this->tank_auth->is_logged_in()) {
     echo "<a href = '#' id ='add_inv'>+Add Category</a>";
     $ajax->Exec('add_inv',$ajax->call(base_url('ajax.php?post/add_inv/'.$subject_id.'/add'), 'lol')); 
    }
    ?>
    </div>

    I am assuming you are passing the $subject_id through parameter in your view, yes?

    This is the code you sent me:

    <div class = "subj-nav"> <?php if(isset($catg_data)) {
    
    foreach($catg_data as $catg) {
     echo "<a href ="#" id = "catg">”;
    
    $ajax = ajax();
    if($this->tank_auth->is_logged_in()){ $logged_in = 1;} else { $logged_in =
    
    0; }
    
    $ajax->Exec('catg'.$catg['catg_id'],
    
    $ajax->call(base_url('ajax.php?post/get_prod/'.$catg['catg_id'].'/'.$logged _in), 'blad'));
    
    }
    
    } if($this->tank_auth->is_logged_in()) {
    
    echo "<a href = "#" id ="add_inv">+Add Category</a>";
    $ajax = ajax();
    $ajax->Exec('add_inv',
    
    $ajax->call(base_url('ajax.php?post/add_inv/'.$subject_id.'/add'), 'lol')); }
  • #135 / Jul 12, 2012 4:24am

    ev0ken

    4 posts

    Thank you I got it to work by just removing the extra $ajax = ajax(); calls. Sorry My code was so rough when i sent it you I’ve only been coding for around 2 months I sent you a rough draft 😛 Thank you for such a quick reply as well.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases