Problems with external js in codeigniter

0

I'm starting to develop with codeigniter. Inside the view I wrote one and it works perfectly. Then, I decide to cut and paste the script to an external file and then include it in the view and I get an error in one of the functions.

This is my script:

    <body>
    <script>function actualiza_carga(info, columna, id) 
    { $.ajax({ url : "<?php echo   site_url('index.php/book/book_update/')?>", 
     type: "POST", dataType: "JSON", 
     data:{ "id": id, "columna": columna, "info": info }, 
     success: function() { alert("Correcto"); }, 
     error: function (jqXHR, textStatus, errorThrown) 
     { alert("Se ha producido un error"); } 
     }); 
      }
     </script>
     </body>

If I put this code in the same php, the result is "true". If I copy and paste in an external file and include it the result is "false".

    <body>.... 
    <script type="text/javascript" src="<?php echo base_url();?>custom/carga.js" ></script> 
    </body></html>

Any clues to solve the problem? Thank you

    
asked by Gaby 04.11.2017 в 02:05
source

0 answers