如何序列化日期以用於AJAX?我正在使用ajax從隱藏的輸入文本框發送日期,並希望序列化它以使用coldfusion運行查詢。使用AJAX序列化日期
HTML(自動接收日期)
JS
var Tmrwdate = $('#TomorrowsDate');
console.log($(Tmrwdate).serialize());
$.ajax({
url: "proxy/TomorrowsDate.cfm",
type: "post",
dataType: "json",
data: {date: Tmrwdate.serialize() },
success: function (data) {
console.log(data);
},
error: function (xhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
代理/ TomorrowsDate.cfm
<cfset session.dealerwork.tomorrowsdate = form.TomorrowsDate >
<cfquery name="tomorrowTextArea">
SELECT *
FROM dbo.Dealer_Track_Work
WHERE Date_Due = <cfqueryparam value="#session.dealerwork.tomorrowsdate#" />
AND Date_Complete IS NULL
</cfquery>
<cfoutput>#SerializeJSON(session.dealerwork.tomorrowsdate)#</cfoutput>
我的控制檯日誌從console.log($(Tmrwdate).serialize());
TomorrowsDate=10%2F28%2F2015
JSON有沒有日期特殊格式所以只要你的客戶和ColdFusion可以達成一致的東西,只是使用它。例如。 YYYY-MM-DD – Henry