CodeIgniter Forums
CI NOOB QUESTION : AJAX - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forum-22.html)
+--- Thread: CI NOOB QUESTION : AJAX (/thread-26352.html)



CI NOOB QUESTION : AJAX - El Forum - 01-11-2010

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


CI NOOB QUESTION : AJAX - El Forum - 01-11-2010

[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.


CI NOOB QUESTION : AJAX - El Forum - 01-11-2010

[eluser]napz[/eluser]
Wow thank you so much Mr. Williams....


CI NOOB QUESTION : AJAX - El Forum - 01-12-2010

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


CI NOOB QUESTION : AJAX - El Forum - 01-12-2010

[eluser]Jelmer[/eluser]
@napz

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)


CI NOOB QUESTION : AJAX - El Forum - 01-12-2010

[eluser]napz[/eluser]
Hmmmmm......

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