PHP - ajax no realiza su redireccionamiento solicitado

 
Vista:

ajax no realiza su redireccionamiento solicitado

Publicado por carlos gutierrez (1 intervención) el 06/09/2017 22:13:30
que tal buenas alguien podría darme una idea del porque mi ajax no esta direccionando de buena manera ??


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
jQuery.fn.ajaxify = function (selector, success, error) {
    // Handle the optional case of selector.
 
 
    if (arguments.length === 2) {
        error = success;
        success = selector;
        selector = undefined;
    }
 
    return this.on('submit', function (e) {
 
         alert('hola mundo');
        //Para obtener el json de la Forma
        var formData = $(this).serializeObject();
        console.log(formData);
        //no llega
        console.log($(this).serialize());
        // Copia las opciones desde la forma '<form />'.
        // Debemos de enviar action = 'ALTA', id = '1' MyJSON = Datos de la forma
        jQuery.ajax({
            url: "../apps/web_codigo.php",
            method: this.method || 'POST',
            data: (typeof selector === 'undefined' ? $(this).serialize() : $(this).find(selector).serialize())
        }).done(jQuery.proxy(success, this)).fail(jQuery.proxy(error, this));
 
        e.preventDefault(); // Don't forget to stop the form from being submitted the "normal" way.
    });
};
 
jQuery(document).ready(function ($) {
    $('form').ajaxify(function (response) {
        //if(response!="Correcto") alert(response);
        if(response==="AltaCorrecta"){
            alert("Alta exitosa.");
            location.href = "http://www.micodigo.com";
            //location.reload();
        }else if(response==="YaExiste"){
            alert("Ya existe una cuenta con estos datos.");
        }else if(response==="ErrorAlta"){
            alert("Ocurrió un error, favor de intentar más tarde.");
        }
    }, function (xhr, error) {
        alert("Ocurrió un error, favor de intentar más tarde.");
    })
});
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Alejandro

ajax no realiza su redireccionamiento solicitado

Publicado por Alejandro (54 intervenciones) el 07/09/2017 20:25:08
Que tal Carlos,

Podrías probar con:

1
window.location.href = "http://www.example.cl";

Saludos.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar