Coldfusion serializeJSON example

ぐ巨炮叔叔 提交于 2019-12-08 03:49:48

问题


I'd like to see a simple template example with SerializeJSON and deserializeJSON posting to the same template and an Array adding each time a pass occurs. I've tried this several times and I keep getting confused by the pass.


回答1:


<cfif structKeyExists(form,"jsonArray")>
    <cfset arrayData = deserializeJSON(form.jsonArray) />
    <cfset arrayAppend(arrayData,form.theText) />
<cfelse>
    <cfset arrayData = [] />
</cfif>
<cfoutput>
    <form name="input" action="ableto.cfm" method="post">
        <input type="hidden" value='#serializeJSON(arrayData)#' name="jsonArray" id="jsonArray" />
        Text: <input type="text" value="" name="theText" id="theText" />
        <input type="submit" value="Subby" />
    </form>
</cfoutput>

<cfdump var="#arrayData#" />
<cfdump var="#form#" />


来源:https://stackoverflow.com/questions/10392604/coldfusion-serializejson-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!