mardi 15 novembre 2016

if else statement appears to run both

In my js erb file, both of my flash message is showing when only one should be. The ajax runs fine and my response is what it is supposed to be. However, for some reason, my flash message takes on the message in both the if and else statement. I put a debugger right before the if statement to test my response and it should've evaluated to true.

$.ajax({
            url: '/purchases/options',
            method: 'post',
            dataType: 'json',
            data: data
            }).done(function(response){
                if(response.duplicate === "true"){
                    <% flash.now[:alert]= 'This Addressi Is Already In Your Cart Or In Your Report Section.' %>
                }
                else{

                    <% flash.now[:notice]= 'Searchs result is added to your cart' %>
                }
           });
    $("<%= j render(:partial => 'layouts/messages') %>").insertBefore('form')[0];

Aucun commentaire:

Enregistrer un commentaire