Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
with out set time out I am not geting value in Product count, it comes undefined, Thanks in advance.

JavaScript
var fdvDdv = function () {

        var RequestBody = {};
        RequestBody.name = "productAssetCount";
        RequestBody.parameters = [null, null];
        var url = utility.webserviceUrl.getInShortDetails;
        utility.postAjaxHelper(url, "POST", [RequestBody]).done(function (fdvDdvdata) {
            //alert(JSON.stringify(fdvDdvdata[0].result));
            //alert(TotalProduct);
            $.each(fdvDdvdata[0].result, function (index, item) {
                setTimeout(function () {
                    if (item.assetTypeId == '0704e697-b0bb-42e1-9555-46dc9a8eeb97') {  //the Id of FDV
                        $('#fdv').html(item.assetCount);
                        // Calculate percent for FDV
                        //var result = parseFloat(parseInt(item.assetCount, 10) * 100) / parseInt($("#price2").val(), 10);
                        fdvpercentage = floorFigure(parseFloat((item.assetCount / TotalProduct) * 100), 1);
                        //alert(fdvpercentage);

                    } else if (item.assetTypeId == 'c5ded83b4c9b-b912-4d46-b1bb-84ff843e') {// the Id of Image
                        $('#imgprodukter').html(item.assetCount);
                        //calculate percent for Bidder(image)
                        bilderpercentage = floorFigure(parseFloat((item.assetCount / TotalProduct) * 100), 1);
                        //alert(bilderpercentage);
                    }
                }, 1000);
            });
        }).fail(function (jqXHR, textStatus, errorThrown) {
            console.log('fail');
        });
};


Thanks for the response, I have created that particular method below is the code

JavaScript
var postAjaxHelper = function (uri, method, data) {
        return $.ajax({
            type: method,
            url: uri,
            dataType: 'json',
            contentType: 'text/plain;charset=UTF-8',
            data: data ? JSON.stringify(data) : null,
        });
    };
Posted
Updated 3-Nov-15 19:28pm
v4
Comments
Richard Deeming 3-Nov-15 9:22am    
Where does utility.postAjaxHelper come from? If it's a method you've written, you'll need to update your question to include the code of that function.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900