title: Codeigniter, Call SweetAlert in Controller
body: <p>I have searching in various webpages, but no one has clear or solve my problem... I come with the expertes, because i need your help... :(</p>
  
  <p>This is my User Controller Method</p>
  
  <pre><code>&lt;?php
  defined('BASEPATH') OR exit('No direct script access allowed');
  
  class UserController extends CI_Controller {
  
  function __construct()
  {
   parent::__construct();
  }
  
  function new_user_register(){
  $this-&gt;form_validation-&gt;set_rules('primernombre', 'First Name','trim|required|alpha|min_length[3]|max_length[100]|xss_clean');
  $this-&gt;form_validation-&gt;set_rules('primerapellido', 'Last Name', 'trim|required|alpha|min_length[3]|max_length[100]|xss_clean');
  $this-&gt;form_validation-&gt;set_rules('nombreusuario','Username','trim|required|xss_clean');
  $this-&gt;form_validation-&gt;set_rules('email','Email','trim|required|valid_email|is_unique[cat_tbl_usuario.email]|xss_clean');
  $this-&gt;form_validation-&gt;set_rules('clave','Password','trim|required|matches[claveConfirmacion]|md5');
  $this-&gt;form_validation-&gt;set_rules('claveConfirmacion','Confirm Password','trim|required|md5|matches[clave]');
  if ($this-&gt;form_validation-&gt;run() == FALSE) {
    echo "&lt;script language=\"javascript\"&gt;
        swal('Please adjust the values in user' , 'Bad data format', 'error');
      &lt;/script&gt;";
    }
  }
  ?&gt;
  </code></pre>
  
  <p>Basically i load my view into a iFrame(FANCYBOX), and i click in the OK button, call the Method new_user_register, and if the validation it's false, then the SWEETALERT, should come out saying the error, except that in the console said that swald isn't defined. And the examples i search aren't too clear to me.</p>