Welcome Guest, Not a member yet? Register   Sign In
prevent direct access to this function/page ?
#11

[eluser]Arun Joshi[/eluser]
how can I download the ajax helper?
#12

[eluser]Dam1an[/eluser]
Just create a file called ajax_helper.php in the helpers directory and put the code bargainph gave earlier in it
#13

[eluser]Thorpe Obazee[/eluser]
Arun, you should not PM people for the same questions. It's what the forum is for.
#14

[eluser]bEz[/eluser]
An alternative method to the HELPER solution would be to create a new constant in:

./application/config/constant.php
Code:
/*
|--------------------------------------------------------------------------
| Define Ajax Request
|--------------------------------------------------------------------------
|
*/
define(
     'IS_AJAX',
     isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
     strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'
);

Line separated for clarity.

Stumbled upon this code while viewing the recent weblee screencast for JQuery (btw, a must view).

You can then change the controller code as follows:
Code:
if (! IS_AJAX)
{
  // not ajax
} else {
  // ajax
}

Subtle change, but it works!




Theme © iAndrew 2016 - Forum software by © MyBB