作者:林志群晴梦 | 来源:互联网 | 2024-09-25 16:15
IamcurrentlyworkingonashoppingcartapplicationusingMVC5andhavearequirementtoallowedi
I am currently working on a shopping cart application using MVC5 and have a requirement to allow editing of the cart which is displayed as a partial view in a jQuery UI dialog.
我目前正在使用MVC5开发购物车应用程序,并且要求允许编辑在jQuery UI对话框中显示为部分视图的购物车。
I have added a Javascript method to allow an ajax call to the controller however I am having an issue with the display of the json result data. At the moment it is rendering as a blank page even though the json data is valid.
我添加了一个Javascript方法,允许对控制器进行ajax调用,但是我遇到了json结果数据显示的问题。目前,即使json数据有效,它也会呈现为空白页。
The jquery code is as follows:
jquery代码如下:
$(".RemoveLink").click(function () {
// Get the id from the link
var recordToDelete = $(this).attr("cartid");
$.ajax({
url: "/ShoppingCart/RemoveFromCart/",
type: 'POST',
datatype: 'html',
data: {
id: recordToDelete
},
success: function (data) {
$("#shoppingcart").html(data);
},
error: function (jqXHR, textStatus, errorstring) {
alert("There has been an error textStatus: [" + textStatus + "] \r\n errorstring: [" + errorstring + "]");
}
})
});
I have attempted to display the data manually and this works successfully however I was hoping I could do it using my partial view as it stands.
我试图手动显示数据,这成功地工作,但我希望我可以使用我的部分视图来实现它。
Thanks,
Stuart
2 个解决方案