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

[eluser]bielco[/eluser]
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 ?

[eluser]Ajaxboy[/eluser]
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.

[eluser]bielco[/eluser]
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.

[eluser]Ajaxboy[/eluser]
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/



[eluser]bielco[/eluser]
[quote author="Ajaxboy" date="1368088107"]
they should be along with:

application
system
index.php
ajax.php
ajaxfw.php
.htaccess <-- this
[/quote]

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 :-)

[eluser]bielco[/eluser]
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.

[eluser]bielco[/eluser]
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.

[eluser]Ajaxboy[/eluser]
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.

[eluser]bielco[/eluser]
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.

[eluser]Ajaxboy[/eluser]
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.

Quote: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.




Theme © iAndrew 2016 - Forum software by © MyBB