求Ajax传参问题 - Web 开发 / Ajax
前台传给后台一个日期值[date],是String类型的,调试获取到值是:2011-12-14
到后台ashx内通过“context.Request["date"]”获取到的值变成了111-12-14
这是为什么?有什么方法可以获取到前台的那个值吗?
前台如下:
$("#btnSubmitMoney").click(function () { var nowDate = ""; //当天日期 var money = ""; //当天销售额 var theDate = new Date(); nowDate = theDate.getYear() + "-" + (theDate.getMonth() + 1) + "-" + theDate.getDate(); money = $("#txtMoney").val(); addNowMoney(nowDate, money);});
function addNowMoney(date, money) { $.post("ajax_API/ajaxapi.ashx", { fun: "AddMoney", date: date, money: money }, function (result) { if (result == "repeat") { alert("“" + date + "”记录已存在!"); } else if (result == "success") { alert("提交成功"); } else if (result == "failure") { alert("提交失败"); } else { alert("未知错误"); } });}
string date = context.Request.Params["date"];