Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用ajax检索后,JSON数据未从中显示到视图_Javascript_C#_Json_Asp.net Ajax - Fatal编程技术网

Javascript 使用ajax检索后,JSON数据未从中显示到视图

Javascript 使用ajax检索后,JSON数据未从中显示到视图,javascript,c#,json,asp.net-ajax,Javascript,C#,Json,Asp.net Ajax,我使用ajax从控制器检索Json数据。但是我试着在一个特定的div中展示结果,尝试了很多东西,但都不知道我做错了什么。我可以在控制台中看到它正在获取json数据,但它只是没有显示在特定的div中 下面是Json数据- Object postage_result: costs: cost:{item: "Parcel Post", cost: "15.80"} delivery_time:"Delivered in 4 business days" service:"P

我使用ajax从控制器检索Json数据。但是我试着在一个特定的div中展示结果,尝试了很多东西,但都不知道我做错了什么。我可以在控制台中看到它正在获取json数据,但它只是没有显示在特定的div中

下面是Json数据-

Object
postage_result:
  costs:
       cost:{item: "Parcel Post", cost: "15.80"}
  delivery_time:"Delivered in 4 business days"
  service:"Parcel Post"
  total_cost:"15.80"
Ajax代码-

<script>
        $.ajax({
            url: '/ShoppingCart/GetFreight',
            type: 'GET',
            success: function (response) {
                console.log(response);

                weather = ko.mapping.fromJS(response);  //populate the weather object
                ko.applyBindings(weather);
                $.each(response.postage_result, function (i, val) {
                    $("#cost").append(document.createTextNode(val.total_cost));
                })

            },
            error: function (error) {
                $(that).remove();
                DisplayError(error.statusText);
            }
        });
    </script>

$.ajax({
url:“/ShoppingCart/get货运”,
键入:“GET”,
成功:功能(响应){
控制台日志(响应);
weather=ko.mapping.fromJS(响应);//填充weather对象
ko.应用绑定(天气);
$。每个(响应.邮资\结果,函数(i,val){
$(“#成本”).append(document.createTextNode(val.total_成本));
})
},
错误:函数(错误){
$(that.remove();
显示错误(error.statusText);
}
});
查看代码-

<td>Freight =<div id="cost"> </div></td>
运费=
请建议我应该怎样做才能工作