ajax parameters,Problem with jQuery ajax parameters

在尝试使用Ajax向Web服务发送日期时,由于日期格式包含'/'字符,导致数据被解析为浮点数。问题在于'/」字符在JSON中被视为特殊字符。解决方法是将日期字符串进行转义或者使用ISO 8601标准格式发送日期。例如,可以将日期转换为'2010-12-14'格式。在JavaScript中,可以使用`new Date().toISOString()`或`moment.js`库来处理日期格式。
摘要由CSDN通过智能技术生成

I'm sending a date to my webservice in this format: 12/14/2010 but the "/" character is causing the posted value to be something like 0.0323483238432834. How do I literally send the date in that format? Heres the ajax code I use:

function createNewPromo() {

var a = $("#txtDateStart").val();

var b = $("#txtDateEnd").val();

$.ajax({

type: "POST",

url: "/WebService_VehicleDisplay.asmx/createNewPromo",

data: "{startDate:" + a + "," + "endDate:" + b + "}",

contentType: "application/json; charset=utf-8",

dataType: "json",

success: function (msg) {

var response = msg.d;

},

failure: function (msg) {

alert('failure');

}

});

}

Edit: here is what firebug says. endDate/startDate are my parameters.(this is what is being posted to my web service.).

JSON

endDate

0.00021321961620469082

startDate

0.00028429282160625445

Source

{startDate:12/21/2010,endDate:12/28/2010}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值