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]
  • #151 / May 07, 2013 7:41am

    bielco

    8 posts

    Hi AjaxBoy,

    Well i did just that, otherwise i would not have posted this message in the first place ?

    But seems you missed my argument that i have not installed CI in the website root, but outside the website root, which can explain why this is not working ?

    Quote…

    Download and unzip the Ajax Framework package, then just overwrite everything from the zip into your CodeIgniter base installation (will not replace any of your files)

    ... end quote

    This is only true when you have installed your framework into the website root right ?
    And the latter is the problem, as i never install in the website root, but one level up.
    The only thing that is in my website root, is img, js, css and the index.php and in this case the ajax.php, ajaxfw.php and ofcourse the cjax folder. All the rest is one level up.

    So that means that all the people that do not install their framework in the website root are out of play with this ajax framework ?

  • #152 / May 07, 2013 10:14am

    Ajaxboy

    243 posts

    It doesn’t have to be on the website root, but it does have to be in the root of your ci installation, meaning along where the ci files reside.

  • #153 / May 07, 2013 1:02pm

    bielco

    8 posts

    So guess i have the next file structure…

    /var/www/vhosts/mywebsite.com

    then everything is installed in that dir, and only the index.php and the .htaccess from codeigniter to into the public dir (public_html when they use directaccess).

    so that means the next structure whereas mywebsite/ is the root and mywebsite/public is the webroot.

    so we have this structure…

    mywebsite.com/ <—- this is not http://mywebsite.com
      application
          controllers
          responses
          views
      cjax ?
      public [the website root] <—- this is http://mywebsite.com
          .htaccess
          index.php
          ajax.php
          ajaxfw.php
      system

    Is that correct ? or does cjax go into the public dir ?
    By the way, i moved it to public also, but seems not to help.

    And ajax and ajaxfw in the public ?
    And the rest in application right ?

    So seems that i did not missed anything correct ?

    However because i use .htaccess for codeigniter, i think that is why it does not work.

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]

    Not sure however, because i get no error messages anywhere, it just prints blanc screen when it do one of the next…

    http://mywebsite.com/ajax.php/test/test
    http://mywebsite.com/ajax.php?test/test

    No errors, totally nothing, just blanc.

    Maybe if i can get it to work, i can update the wiki or docs for you to list the two scenario’s for member to install on their codeigniter framework. But i have no luck with it that far.

  • #154 / May 09, 2013 4:28am

    Ajaxboy

    243 posts

    Your file structure currently used is wrong. No where in the docs does it say to put the files under public directory?

    Instead of putting these files:

    public [the website root] <—- this is http://mywebsite.com
        .htaccess
        index.php
        ajax.php
        ajaxfw.php
      system

    they should be along with:

    application
    system
    index.php
    ajax.php
    ajaxfw.php
    .htaccess <—this

    If you are using htaccess, you will need to update your .htaccess file pointed above with the content that is found in htacces.txt. If there is already a htaccess file, you will need to merge the two, please see this post for more info:

    http://ellislab.com/forums/viewthread/220620/

     

  • #155 / May 09, 2013 8:29am

    bielco

    8 posts

    they should be along with:

    application
    system
    index.php
    ajax.php
    ajaxfw.php
    .htaccess <—this

    That doesn’t work ajaxboy. As the index.php and ajax.php need to be in your website root, otherwise you can never reach them right ?

    In other words, if i put my index.php of codeigniter at the location you mention here, then my website will be offline, because there is no index.php in website root.

    So i just conclude even you have no idea how to really fix this, as you propably never have installed the codeigniter framework outside the website root.

    We might be able to fix this together and i will then update the documentation for an out-of-webroot install. But what is posted here is not going to work out. Because you can never request a file outside the website root. So that means ajax.php should be in website root, or you never can call the file in the first place, so despite the above message is a no-go.

    We’ll get there someday 😊

  • #156 / May 09, 2013 10:20am

    bielco

    8 posts

    Did some further investigation.

    The AjaxController gets loaded without problems.
    The cjax folder and the ajax.php and ajaxfw.php are accessed from webroot,
    as it is programmed that way.

    I ran into white screens as i was saying, so i started to debug,
    here are my findings that far…

    cjax/cjax.php line 34 sets file to ajax.php
    but it turns out that my $_SERVER[‘SCRIPT_NAME’]
    seems to be “/ajax.php” which tells me something
    breaks on line 36, and it returns “/ajax.php”, which
    ofcourse returns true on line 39 and there are your
    white screens.

    When i commented out line 36 that bumped me into
    another nice error, which says…

    Controller File: test.php not found

    Anyway that means it continues and not breaked out
    on line 39, so i guess we’re almost there 😊

    So i will keep debugging, but there is your first fix 😊
    I am despite not good with regular expressions.

  • #157 / May 09, 2013 10:32am

    bielco

    8 posts

    ajax view…

    Ajax Controllers work great.


    View: test2

    There you go 😊

    So it works great, although i would really prefer only the ajax.php in the webroot, and all the rest outside of it.
    So i will keep trying until i get that done, and i’ll let you know what needs to be changed for an out-of-webroot
    based install.

  • #158 / May 10, 2013 5:56pm

    Ajaxboy

    243 posts

    there should be an index file in the root of your application, and it shouldn’t matter in what sub-directory it’s installed, it should work.

  • #159 / May 11, 2013 7:06am

    bielco

    8 posts

    Well ajaxboy, that is a valid statement.

    It SHOULD work, but despite… it doesn’t.

    But it is ok, it is clear i am not gonna get help here.

    And last but not least… it DOES matter where the cjax dir is being placed,
    because if it is placed outside the website root then the cjax framework breaks.

    This is because of the simple fact that the js scripts it needs from the
    framework should be in website root, because otherwise they are unavailable
    for the request to the server. Just like images, css files and other js scripts
    should be in the website root because they are not available otherwise.

    Anyway, i got it working now, by just putting the cjax dir in the website
    root and putty ajax.php and ajaxfw.php in the website root too.

    And the last argument, if ajax.php is in the website root and ajaxfw.php
    is one level up from the webroot, then FCPATH points to the website root,
    and guess what ? Your controller will break because it tries to load the
    ajaxfw.php from the FCPATH, which is in this case ... you got it, the website
    root. So when ajaxfw.php is placed outside the website root your controller
    will never be able to find it.

    So your argument you can install it anywhere is invalid.

  • #160 / May 11, 2013 8:45am

    Ajaxboy

    243 posts

    It may work if you place some of the package contents in the public directory, but it is not designed to reside there, so you may experience alot of issues in the future for that simple fact.

    Sounds like you need to follow the suggestion I made in the earlier post of updating your htacces file. That will allow access to ajax.php and ajaxfw.php.  The rest on the content in cjax directory have their own htaccess files. You will not be getting “unavailable requests”.
    Is not that I don’t want to help, I just don’t know how to put it anymore clear, I say it should work because 99% of users have got it working, and the rest 1% who have had issues have followed these suggestions and got it working, that is why I say it should work. You might want to set up your htaccess file correctly, and follow the instructions.

    Your controller will break because it tries to load the
    ajaxfw.php from the FCPATH,

    That is the correct behavior, ajax controllers are server through either ajaxfw.php or ajax.php.

  • #161 / May 16, 2013 6:50am

    xorzizten

    4 posts

    Hi!

    I’m about to start a new project using CI, and would like to start learning and using the cjax library.
    Let it be said that i’m farly new to CI, and just about learned about cjax, so please have me excused if my questions is somewhat ‘noob’ 😊

    I uploaded a new set of CI files and the cjax files to my webserver, changed a few config settings like base_url, encryption_key and a few other basic CI settings.
    This is a dev server, so all files and folders are in the same root folder, and so far i have not set up any htaccess file.

    When i access my new project, the CI default works, but when i try to access ajax.php?test/test i get this error:

    Fatal error: Class 'CI_Controller' not found in /home/14/w213454/www/portal_v2/application/response/test.php on line 3

    Where line 3 in response/test.php says:

    class Test extends CI_Controller {

    I have tried searching for an answer online, and read around in the cjax documentation, but have not forund an answer that have helped.

    I’m hoping you guys maby could take some time to help me out on this one 😊 ?

    And i’m sorry if this question have been answed before, but if it have, i’ve not found it.

    Regards
    Kjell Arne

     

  • #162 / May 16, 2013 7:26am

    Ajaxboy

    243 posts

    Yes it has, I believe it as to do with strict standards being turned on,  you might want to check on that and make sure you turn off strict-standards in your php.ini,  what version of Cjax are you using?  the latest version (;latest Cjax is currently 5.4) does make an attent to disable it automatically, but you might want to double check and make sure is fully turned off.

  • #163 / May 16, 2013 3:55pm

    xorzizten

    4 posts

    Hi again, and thanx for a fast reply.

    As far as i know i have disabled the E_STRICT..

    i have set

    ini_set('display_errors', 1);
    ini_set('log_errors', 1);
    error_reporting(E_ALL & ~(E_STRICT|E_NOTICE));

    in ajax.php and

    error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT

    in the php.ini

    But the problem still stands ? I cant seem to figure it out..

    I do not have access to the main php.ini file, but can use a local php.ini in my webroot.. And according to the provider the strict standar is possible to disable from my local file..

    Regards
    Kjell Arne

  • #164 / May 16, 2013 4:05pm

    Ajaxboy

    243 posts

    You might want to try it directly from your php.ini instead of through php, I recall someone had to do that to get it to work. Make sure you restart your server, then try again, if that fails - then it’s probably something else.

  • #165 / Jul 11, 2013 2:51pm

    fran-quero

    19 posts

    Hello Ajaxboy.

    Thank you very much for sharing your great Ajax framework. It’s awesome, I’m still hallucinated, thinking that it must be magic!

    I’ve been playing around with some examples, and trying to replace some .jquery (.js) files with $ajax methods. Most of my tests have worked like a charm, but there is one where I’m stucked.

    EDIT: Forget the problem description described below. It’s solved and explained at the end of the post

    What I have working in jquery and can’t run with cAjax is adding HTML generated by $ajax->call to a select form. I have a zip_code input, and when it loses focus I take populations from the database and generate <option> to fill a select with.

    I post my code here, so you can illuminate my path:

    Working example with hardcoded <option>

    $ajax->Exec('zip', $ajax->update("population", array('innerHTML'=>'<option>Foo</option>')), 'blur');

    The problem is when I change hardcoded <option> for an $ajax->call()

    $ajax->Exec〈'zip', $ajax->update("population", array('innerHTML'=>$ajax->call('ajax.php?newuser/populations/|zip|'))), 'blur');

    EDIT
    Very easy solution. Just have to do so:

    $ajax->Exec('zip', $ajax->call('http://localhost/ajax/newuser/populations/|zip|','population'), 'blur'〉;

    The only thing I have to find out is why it doesn’t work the url ajax.php?newuser… and I have to use the absolute url.

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

ExpressionEngine News!

#eecms, #events, #releases