weixin_33709219 2017-12-26 08:29 采纳率: 0%
浏览 52

Json在asp.net MVC中不起作用

I wanna to use this json to my sites shopping cart .it works well in visual studio 2017 but in visual studio 2013 it does not work. please help me to solve it.

function AddtoCart() {
  $.ajax({
    url: '/Home/AddToCart',
    type: 'POST',
    dataType: 'Json',
    data: {
      ProductID: @Model.product.id,
      count: My_Count.value
    },
    error: function(err) {
      alert(err.status);
    }
  }).done(function(data) {
    $('#Total_Cost').text(data.Total_Price)
    var Text = "";
    $.each(data.lst_ShoppingCart, function(index, val) {
      Text += "<tr><td class='col-sm-8 col-md-6' ><span id='Product_Name'>" + val.Product_Name + "</span></td ><td class='col-sm-1 col-md-1' style='text-align: center'><input type='text' class='form-control' id='exampleInputEmail1' value='" + val.Count + "'></td><td class='col-sm-1 col-md-1 text-center'><span id='Product_Cost'>" + val.Single_Price + "</span></td><td class='col-sm-1 col-md-1 text-center'><span id='Total_ProCost'>" + val.Price + "</span></td><td class='col-sm-1 col-md-1'><button type='button' onclick='RemoveCart(" + val.ID + ")' class='btn btn-danger'>Remove</button></td></tr>";
    })
    $('#Pro_Cart').html(Text);
  });
}

also I know that this part of code not working:

url: '/Home/AddToCart',
  type: 'POST',
  dataType: 'Json',
  data: {
    ProductID: @Model.product.id,
    count: My_Count.value
  },

</div>
  • 写回答

0条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 房号如何排序,sql或算法
      • ¥15 macOS使用IDEA 2022.2.4打包JDK6项目报错
      • ¥20 OpenCV-Python简单轮廓寻找
      • ¥20 使用matlab进行含参数的最优化求解及数值模拟
      • ¥20 MATLAB找出一维变量中的局部极大值和局部极小值,并进行运算
      • ¥15 有Chang求三维杆单元几何非线性分析matlab代码
      • ¥50 使用unity easyar录屏功能。录屏视频整体色调很暗
      • ¥50 pyinstaller 打包问题
      • ¥15 无法使用cnssc调取网页数据
      • ¥15 Pycharm安装en_core_web_sm失败出现Could not find a version that satisfies the requirement spacy报错