I want to refresh the product page automatically if the user clicks on "CHECK" button of zipcode field. I want to refresh the page automatically every time user click on CHECK button of zipcode or want to refresh the add to cart button & zipcode section as i marked in attached screenshot. I am providing you the cod.phtml
cod.phtml
<?php
/***************************************
*** Cash On Delivery ***
**************************************
*/
$msgData = Mage::helper('netgo_cod')->getConfigData();
if($msgData['zip_status'] == 1){
?>
<div class="input-box">
<div class="z-btn">
<label>Zip Code : </label><input type="text" placeholder="Enter your pincode" value="" name="cod" class="product-custom-option required-entry" id="cod" size="29" style='color:black; font-size:12px'>
<button type="button" onclick="checkCOD();" name="zip-check" title="Check" class="button" id="zip-check"><span><span>Check</span></span></button>
</div>
<div id="cod_msg"></div>
</div>
<script>
function checkCOD(){
var zipcode;
var cod = $('cod').value;
if(cod == ''){
$('cod_msg').update('<span class="cod-error"><?php echo $msgData['emp_msg']; ?></span>');
return
}else{
$('cod_msg').update('<img src="<?php echo Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB, true ).'media/cod/img/ajax-loader-2.gif';?>">');
new Ajax.Request('<?php echo Mage::getBaseUrl().'netgo/cod/check';?>', {
method:'post',
parameters: {zipcode: cod},
onSuccess: function(transport) {
var response = transport.responseText || "no response text";
$('cod_msg').update(response);
if(response.search('Delivery of the book is not available on the above pincode')!=-1)
{
zipcode='checked';
jQuery('.btn-cart').attr('disabled', 'disabled');
}
else
{
zipcode='';
}
},
onFailure: function() { alert('Something went wrong...'); }
});
}
}
</script>
<?php } ?>
Screenshot: