求Ajax传参问题

昵称可以很长很长很长 2011-12-14 03:30:27
前台传给后台一个日期值[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("未知错误");
}
});
}


后台是这样获取的:
在ashx中,context.Request["date"]也试过

string date = context.Request.Params["date"];
...全文
249 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
ws20110318 2011-12-14
  • 打赏
  • 举报
回复
邮箱是什么,给你发个案例。
js.ajax调用webservice或者ashx;jquery.ajax()调用webservice或者ashx。
阿非 2011-12-14
  • 打赏
  • 举报
回复
nowDate = theDate.getYear() + "-" + (theDate.getMonth() + 1) + "-" + theDate.getDate();
=>
nowDate = theDate.getFullYear() + "-" + (theDate.getMonth() + 1) + "-" + theDate.getDate();
--------------

string date = context.Request.Params["date"];
=>
string date = context.Request.Form["date"];
三石-gary 2011-12-14
  • 打赏
  • 举报
回复
前台执行完提示的信息是什么。。。

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧