使用AJAX序列化日期

How do I serialize a date to use for ajax? I am using ajax to send a date over from a hidden input textbox and want to serialize it to run a query with coldfusion.

HTML (automatically receives date)

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);
            }
        });

proxy/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>

my console log from console.log($(Tmrwdate).serialize());

TomorrowsDate=10%2F28%2F2015
查看全部
weixin_33739523
weixin_33739523
2015/10/27 17:17
  • serialization
  • ajax
  • javascript
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信

2个回复