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

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -