javascript - Serialize a date with AJAX -
how serialize date use ajax? using ajax send date on hidden input textbox , want serialize run query 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 * dbo.dealer_track_work date_due = <cfqueryparam value="#session.dealerwork.tomorrowsdate#" /> , date_complete null </cfquery> <cfoutput>#serializejson(session.dealerwork.tomorrowsdate)#</cfoutput>
my console log from console.log($(tmrwdate).serialize());
tomorrowsdate=10%2f28%2f2015
you shouldn't need serialize date, send value in data argument.
js
var tmrwdate = $('#tomorrowsdate').val(); $.ajax({ url: "proxy/tomorrowsdate.cfm", type: "post", datatype: "json", data: {date: tmrwdate }, success: function (data) { console.log(data); }, error: function (xhr, textstatus, errorthrown) { console.log(errorthrown); } });
proxy/tomorrowsdate.cfm
<cfset session.dealerwork.tomorrowsdate = form.tomorrowsdate > <cfset result = { tomorrowsdate = form.tomorrowsdate} /> <cfquery name="tomorrowtextarea"> select * dbo.dealer_track_work date_due = <cfqueryparam value="#session.dealerwork.tomorrowsdate#" /> , date_complete null </cfquery> <cfoutput>#serializejson(result)#</cfoutput>
Comments
Post a Comment