[eluser]mad82[/eluser]
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
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
Code:
<?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>
<h2>Simple ajax request binded to a button</h2>
<input type='button' id='button1' value='Click this button to make an ajax request'>
</body>
</html>