Redirect to an action or action Javascript PHP

1

I have this doubt, I want to make a validation if the condition is met, show me an alert and redirect me to a specific page but since I am working in MVC, I must do it through an action: the code I have is the next:

<script type="text/javascript">
    alert("Esto es una alerta");
    window.location.href = "archivo.php";
</script>

Where it says file.php I'd like to place an action, I know it's not as simple as replacing the name of the file and placing the action, I guess I should work on pure php. I appreciate any help

    
asked by Luis Alfredo Serrano Díaz 04.07.2018 в 15:10
source

2 answers

0

To perform this validation is quite simple, you should only place the url with the action, example:

<script type="text/javascript">
    alert("Esto es una alerta");
    window.location.href = "www.tupagina.com/carpeta/?accion=tuaccion";
</script>
    
answered by 04.07.2018 в 16:00
0

I do it in the following way, since in MVC you use a base_url that is the root folder of your project in this case I use CodeIgniter and I do it like this:

$(document).on("click",".btn-cerrar-imp", function(){

    window.location.href = base_url + "movimientos/ordenes";

});

This what a jQuery does is that by clicking on the button with the id class btn-close-imp that is in a modal window, redirects me to movements / commands that is my view.

Where in the config.php is the base url:

$config['base_url'] = 'http://localhost/ventas/';
    
answered by 04.07.2018 в 16:25