﻿jQuery(document).ready(function() {

    // Add an item to the list through AJAX.
    $("#recommend").bind("click", function() {
        $.ajax({
        url: "/Service/AddToRecommended?userId=" + $("#userId").val() +
                            "&productId=" + $("#productId").val() +
                            "&tzo=" + $("input#tzo").val(),
            type: "POST",
            dataType: "json",
            contentType: "application/json; charset=utf-8",
            success:
                    function(result) {
                        var obj = JSON.parse(result);
                        $("div.product-status").show();
                        if (obj.error) {
                            $("div.product-status")
                                .text(obj.error)
                                .show()
                                .fadeOut(3000);
                            // .remove();
                        } else {
                            $("div.product-status")
                                .text("Successfully recommended.")
                                .show()
                                .fadeOut(3000);
                            // .remove();
                        }
                    }
        });
    });

});
