Welcome Guest, Not a member yet? Register   Sign In
problem when trying to access a controller function from view using Cjax methods
#1

[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>
&lt;input type='button' id='button1' value='Click this button to make an ajax request'&gt;
&lt;/body&gt;
&lt;/html&gt;
#2

[eluser]Ajaxboy[/eluser]
What error are you getting?
#3

[eluser]Ajaxboy[/eluser]
What I can see from here is that you are including file 'ajax.php', instead use 'ajaxfw.php' (For the CodeIgnater package).

so instead of:


Code:
require_once "ajax.php";

use

Code:
require_once "ajaxfw.php";



cj
#4

[eluser]mad82[/eluser]
Hi,Thanks for your suggestions, problem is rsolved.
#5

[eluser]CroNiX[/eluser]
Was that a copy/paste? Because __construct() should have 2 underscores and you only have 1.




Theme © iAndrew 2016 - Forum software by © MyBB