• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI NOOB QUESTION : AJAX

#1
[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?

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

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

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

#5
[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)

#6
[eluser]napz[/eluser]
Hmmmmm......

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.