【发布时间】:2010-12-14 09:51:31
【问题描述】:
嗨
我在我的应用程序中使用了 jquery,但我遇到了问题,但我认为有必要查看这段代码:
$("#btnAddToBasket").click(function () {
var id = $("#ProductIDAtBasket").text();
var count = $("#BasketAddedValueText").val();
//ajax request
$.ajax({ type: "Post",
url: "Services/NewE_ShopServices.asmx" + "/" + "GetPrice",
data: "{" + "count" + ":" + count + ", goodcode : " + id + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: AjaxSucceeded,
async: true,
cache: false,
error: AjaxFailed
});
});
function AjaxSucceeded(result) {
var res = result.d;
res = res.split(';');
$("#spanFinalPrice").text(res[2]);
$("#spanAbsolutePrice").text(res[3]);
$("#spanDiscount").text(res[4]);
$("#spanCount").text(res[1]);
$("#AddBasketDiv").hide("slow");
}
function AjaxFailed(result) {
alert(result.responseText);
}
正如您在下面看到的那样,有一个 ajax 向 Web 服务发送方法,我获取值并使用 ajaxsucceeded 方法将结果放入页面中,它工作正常且合适,但我的问题是它是购物篮查看器,我想成为例如,当您转到其他页面并返回它时,在此页面中更永久,包含将被省略 我可以在 web 服务类中使用会话和 cookie,但是我如何从 jQuery 代码中读取?什么是解决方案还有其他解决方案吗?
【问题讨论】:
-
我不知道你在问什么
-
听起来您的问题不在于 jQuery,而在于您如何构建服务器端代码。用你提供的数据真的不可能回答这个问题。
-
就是这么简单的hashtable对象,通过json在web service方法中序列化,然后返回页面
标签: c# asp.net web-services jquery