EllisLab text mark
Advanced Search
     
CI NOOB QUESTION : AJAX
Posted: 12 January 2010 01:44 AM   [ Ignore ]
Joined: 2010-01-11
54 posts

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?

 
Posted: 12 January 2010 02:06 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2006-07-27
2617 posts

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.

 Signature 

Check out the Template Library
Oh yeah, I tweet, too (regarding CodeIgniter on occassion).

 
Posted: 12 January 2010 02:19 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2010-01-11
54 posts

Wow thank you so much Mr. Williams….

 
Posted: 12 January 2010 02:20 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2009-08-20
243 posts

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.

 Signature 

// Because killer robots like unicorns!

 
Posted: 12 January 2010 02:37 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2007-03-10
451 posts

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

 Signature 

Starting with CodeIgniter setup
Senior dev of FuelPHP

 
Posted: 13 January 2010 12:28 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Joined: 2010-01-11
54 posts

Hmmmmm…...

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