vendredi 5 août 2016

Javascript and jquery if function is not working

Help me! I have this kind of code but it never goes to IF function? What is wrong? jquery is working but does alert kill IF funtion? IF funtion is working without jquery.

$.get("www.example.com", function(data) {
    var param = 'name'
    param = param.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + param + "=([^&#]*)"),
        results = regex.exec(data);
    var paramValue = results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
    alert(paramValue);
});

if (name == 'Bob') {
    window.location = ("www.example.com");
} else {
    window.location = ("www.example.com");
}

Aucun commentaire:

Enregistrer un commentaire