GIF89a php
Current File : /home/hencockfreshchic/public_html/app_old/js/applyCouponCode.js
function applyCouponCode()
{
	var coupon=$("#coupon").val();

	if(coupon=="")
	{
		popUP("Enter coupon code");
		$("#coupon").focus();
		return false;
	}
	if(coupon.length<2)
	{
    popUP("Invalid coupon code");
		$("#coupon").focus();
		return false;
	}

	if (window.XMLHttpRequest) {
            xmlhttp = new XMLHttpRequest();
        } else {          
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } 
  xmlhttp.onreadystatechange=function() 
   {
    if (this.readyState==4 && this.status==200) 
	{
      if(this.responseText==1)
      {
        popUP("Coupon applied successfully");
        setInterval(function(){  
          window.location.reload();
          },1200);
      }
      else if(this.responseText==3)
      {
        popUP("Already applied");
      }
      else
      {
        popUP("Coupon code not found");
      }	
	}
  };
  xmlhttp.open("GET","applyCouponCode.php?coupon="+coupon,true);
  xmlhttp.send();

}


function popUP(msgg)
{
  var x = document.getElementById("snackbar");
          $("#snack_msgg").html(msgg);
          x.className = "show";
        setTimeout(function(){ x.className = x.className.replace("show", "Hello"); }, 2500);
}