I’m attempting to create a modal on a form that calls a CFC to update data and return results based off a combination of examples I’ve found on the internet and some research. I’ve got it working more or less, but I’m running into a weird problem when defining my arguments where my passed values are entering my CFC function as a comma-delimited string duplicate of the value I pass. My code looks something like this:
Javascript:
var amodal = $("##my-modal-form").dialog({
bgiframe: true,
modal: true,
buttons: {
'Update Data': function() { $("##modal-form-test").submit(); },
Cancel: function() { $(this).dialog('close'); aform.resetForm(); }
}
});
submitHandler: function(form) {
jQuery(form).ajaxSubmit({
target: '##client-script-return-data',
data: {
fullname: $('##fullname').val(),
email: $('##email').val()
},
success: function() { $('##my-modal-form').dialog('close'); successEvents('##client-script-return-msg'); }
});
}
ColdFusion:
<cffunction name="userModalTest" access="remote" output="false" returnformat="json">
<cfargument name="fullname" type="any" required="true" default="" hint="unknown arg type" />
<cfargument name="email" type="any" required="true" default="" hint="" />
<cfset var testVar = '' />
<cfset testVar = serializeJSON(arguments) />
<cfreturn testVar />
</cffunction>
When I pass in my text string arguments and dump the struct, my fullname and email arguments are duplicated values, like “fullname: test,test” instead of “fullname: test”. I can make this stop by either not defining the data values in the submitHandler function or not defining the arguments in the CFC, but to my understanding neither of those solutions should actually work, so I don’t quite understand what’s happening.
Since you are submitting the form no need to pass the
dataattribute toajaxSubmit()call.I think this is causing the ajax submit to submit an array of input params called
fullnameandemail. That array is getting submitted as the coma separated string in the server.Can you remove the
dataand try.Ex: