How to do Ajax Post in jQuery

Nov 29, 2012   //   by kdecom   //   zend framewok 2, zf2  //  No Comments

Here is a very small tips for web developer to do a ajax post using a jquery.

var Default_Home = {

init: function() {
    jQuery('.total-review .hiddenGroup form button').click(self.submitReviewClick);
},
submitReviewClick: function(e) {
    e.preventDefault();
    if (jQuery('.review_value').val() <= 0 ) {
        alert('Please Select Reviews');
        return;
    }
    if (jQuery('.review_text').val() == "" ) {
        alert('Please Write Something about it.');
        return;
    }
 
    jQuery.ajax({ 
        type: "POST",
        url: siteURL + '/item/index/submit-review',
        data: jQuery(e.target).parents('form').serialize(),
        success: function(data) {
            if(data == 'saved') {
                jQuery('.total-review').html('<div class="et-download"><div class="et-box- content">Thanks for Submitting Review.</div></div>');
                }
           }
       });

    }
}
jQuery(window).ready(Default_Home.init);

Leave a comment

css.php