CodeIgniter Forums
javascript event on controller ? - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: javascript event on controller ? (/thread-36361.html)

javascript event on controller ? - El Forum - 11-29-2010

Hi, i'm trying to include a javascript alert on a controller function but it seems like doesnt work. I'm just started with AJAX and JS codding.

Here is pertinent function from my view
function checkBan(){
       type: "POST",
       url: "xxxxxxxxxxxxxxxxxxxxx/fmchat/check_ban",

setInterval (checkBan, 1500);

This is my controller function
function check_ban() {
      if ($this->session->userdata('ban')<>'') {
        <.script language="JavaScript" type="text/javascript">
           .alert('User banned');  

I dont know if it's an ajax problem or just javascript is not allowed on controllers.
I'll regards every kind of tip, help or comment.

javascript event on controller ? - El Forum - 11-29-2010

[eluser]Michael Wales[/eluser]
You should really keep your JavaScript w/ your JavaScript and your PHP w/ your PHP. I would have my controller respond with a JSON response, handle that with the JS callback.