1

Magento 1.9.1 I have added popup after clicking on ad to cart button but the page is reloading before before closing the popup, Please let me know how can

http://onlineflowersdelivery.com/new/index.php/flowers-3/lovely-smile.html

Popup code and script

<pre><div>
        <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('pop_related_products')->toHtml() ?>

 </div>


    jQuery("#bestprice").click(function(event) {
        jQuery("#popup_overlay").show();
        jQuery("#popup_form").show();
    });

    jQuery(".cancel_form").click(function(event) {
        jQuery("#popup_overlay").hide();
        jQuery("#popup_form").hide();
    }); 



jQuery("#price_form_submit").click(function(e){
    e.preventDefault();
    name = jQuery("#price_form_name").val();
    email = jQuery("#price_form_email").val();
    phone = jQuery("#price_form_phone").val();
    sku = 'f700';
    url = window.location.protocol + "//" + window.location.host + "/" + window.location.pathname;
    data = "name="+name+"&email="+email+"&phone="+phone+"&sku="+sku+"&url="+url;
        jQuery.ajax({
          url: 'getBaseUrl() ?>/custom/prod_best_price.php',
          dataType: 'html',
          type : 'post',
          data: data,
          success: function(res){
                //alert(data.top_cart);
                if(!res)
                {
                    alert("You will get an sms or mail with your best price in 5 mins!");
                    //jQuery(".close-reveal-modal").click();
                    jQuery("#popup_overlay").hide();
                }else alert(res);
            }
                    });
});


Button Code is

" id="bestprice" class="button btn-cart" onclick="productAddToCartForm.submit(this)">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.