Welcome Guest, Not a member yet? Register   Sign In

I'm using Prototype for my AJAX, and I'm wondering that is it possible to use the MODEL class to send an echo of a request from View.

if possible how?

I use to forward a request directly to the controllers in my view:

function sendRequest() {
new Ajax.Request("<?php echo base_url(); ?>system/application/controllers/ajax.php"

and the result is an error:

Fatal error: Class 'Controller' not found in C:\xampp\htdocs\MYFIRSTCI\system\application\controllers\ajax.php on line 3
the class Controller is not found. maybe because im directly calling the controller ajax from my view.

what is the possible solution guys?

[eluser]Colin Williams[/eluser]
I think you are REALLY confused about how a web server works, what a URI is, etc. Your URI should look something like /controller/function/id, not a full system path. The request happens over HTTP, not on the filesystem.

Wow thank you so much Mr. Williams....

Pretty sure what he was saying was that your sendRequest function is not pointing to the right place. It should be pointing to something like $base_url/index.php/ajax/ajax_method.


You do realize there's a huge difference between client side scripts (Javascript/Ajax) and server side scripts (PHP/CodeIgniter)?

Client side scripts can only do what your webbrowser allows it to do (or is capable of). In order to get a client side script to do server side actions (example: saving something to the database) you need to create a controller that accepts the Ajax.request post vars and saves them using your model.

First try to understand what you can and can't do with client side scripts (there're some things called Google, Wikipedia and probably the JavaScript library's documentation that can help you there)


Thanks.... I can now do server request(Ajax).... pretty cool with model class!

Theme © iAndrew 2016 - Forum software by © MyBB