I hope this is an easy fix but here is my situation.
The user enters a record number and retrieves back a form with with X number of rows (the data feed is from an external data feed so I cannot control how the data is entered). I'm using jQuery to serialize the form vars and then sending this information to another page via an ajax call. On the action page, I'm looping over the data by the & sign (coldfusion cfloop). The problem that appeared today is that in some cases, one of the form fields may contain the ampersand (&) which breaks the loop on the action page.
Anyone have any suggestions on how to get around this?
Here is my ajax function
var str = $("#ResourceRequest").serialize();
$.ajax({
type: "POST",
url: "index.cfm?do=misc.submitRequest&wddxString=" + encodeURIComponent(str),
data: str,
contentType: "application/json; charset=utf-8",
dataType: "html",
beforeSend: function() {
// $('#spinner').css("visibility","visible");
},
success: function(data) {
// $('#spinner').css("visibility","hidden");
$('#submitRequest_status').html(data);
$('#btnSave').html('Submit Request').attr('disabled','');
},
error: function() {
$('#btnSave').html('Submit Request').attr('disabled','');
// $('#spinner').css("visibility","hidden");
alert("We apologize for the inconvenience but\nwe were unable to process your request. [error: 258]");
// $('#submitRequest_status').html('');
}
});
And here is my CFLOOP
<cfset var i=0>
<cfloop list="#s#" index=curr_val delimiters="&">
<cfset attr=ListGetAt(curr_val & " ",1,"=")>
<cfset val=ListGetAt(curr_val & " ",2,"=")>
<cfif attr EQ "vpmo">
<cfset PROJVPMO=ListAppend(PROJVPMO,val)>
<cfelseif attr EQ "projectname">
<cfset PROJNAM=ListAppend(PROJNAM,val)>
<cfelseif attr EQ "pmt">
<cfset PROJPMT=ListAppend(PROJPMT,val)>
<cfelseif attr EQ "kickoff">
<cfset PROJKIC=ListAppend(PROJKIC,val)>
<cfelseif attr EQ "goLive">
<cfset SYSGOLI=ListAppend(SYSGOLI,val)>
</cfif>