调用服务器端方法的时候遇到一个jquery类型转换的问题,求解
用jquery调用服务器端的方法LoadCartItems获得购物车数据
Jquery代码如下:
           $.ajax({
                 type: "POST",
                 url:"WebServices1.asmx/LoadCartItems",
                 ...
                 ..
                 success: function (result) {
                  $(result.d).each(function (i) {
                      totalPrice += this.Price * this.Quantity;  //  计算购物车数据的总价
                   })
                  $("#lblTotal").html(totalPrice);     
                }
             });
  Web方法如下:
    [webMethod]
     public ICollection<CartInfo> LoadCartItems(string bookId)
     {
           CartManager cartManager = new CartManager();
           string userName = HttpContext.Current.User.Identity.Name;                
           cartManager.GetCartItems(userName);        
           if(bookId!="")
           {
               cartManager.Add(bookId);       
           }           
           cartManager.SetCartItems(userName);
           return cartManager.CartItems;   
     }
     我想让总价显示为单精度型,后面要跟两位小数,但是现在this.Price是decimal,this.Quantity是int型,得到的结果是一个整数,如何才能转化为带小数的单精度型?  
------解决方案--------------------
totalPrice.toFixed(2);
保留2位小数,四舍五入。