EllisLab text mark
Advanced Search
     
problem when trying to access a controller function from a view using Cjax methods
Posted: 14 August 2012 06:00 AM   [ Ignore ]
Joined: 2012-07-22
10 posts

Hi, I got a problem when trying to access a controller function from a view using Cjax methods, its bit frustrating me, any help is greatly appreciated, Below is the code i used
controller file
code
class Gethint extends CI_Controller {
function _construct()
{
  parent::_construct();
  $this->load->helper(array(‘form’,‘url’));
 
      }

public function index()
{
  $this->load->view(‘click_ajax_request’);
}

function click_button($message)
{
  echo “Button clicked”;
  $ajax = ajax();
 
  $ajax->success(“You clicked the button.. $message”);
 
}
}
?>

Here is the View file

<?php
require_once “ajax.php”;
$ajax = ajax();
$ajax->Exec(“button1”,$ajax->call(“ajax.php?gethint/click_button/Hello!”));
?>
<html>
<head>
<?php echo $ajax->init();?>
</head>
<body>

Simple ajax request binded to a button

<input type=‘button’ id=‘button1’ value=‘Click this button to make an ajax request’>
</body>
</html>

Please somebody help me to get out of this

 
Posted: 08 October 2012 09:10 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2012-10-08
5 posts

please try this one , you need to require ajaxfw.php instead of ajax.php.