In my Rails 5.2.3 project, I am attempting to send an AJAX request that includes a JSON representation of a callflow object (the specifics of which are not relevant). This JSON representation is located within a textarea with the id "newCallflowJsonDisplay". Here is an example of the JSON:
{
"callflow": [
{
"action": "dial",
"options": {
"destination": 12121218
},
"label": "-"
}
]
}
The javascript code I am utilizing is as follows:
return new Promise(function(resolve, reject){
Rails.ajax({
url: `some url`,
data: `callflow_json=${document.getElementById('newCallflowJsonDisplay').value}`,
type: "POST",
success: function(response){resolve(response)},
error: function(response){reject(response)}
});
}).then(function(res){
console.log(res);
}).catch(function(error){
logError(error);
})
When using the JSON representation and code provided above, everything functions as expected. The "label" key has a value of "-". I can see in my log:
<ActionController::Parameters {"callflow_json"=>"{\n \"callflow\": [\n {\n \"action\": \"dial\",\n \"options\": {\n \"destination\": 12121218\n },\n \"label\": \"-\"\n }\n ]\n}", "controller"=>"callflows", "action"=>"manipulate", "callflow_id"=>"61"} permitted: false>
However, when I use the JSON below where the value for the "label" key is "+":
{
"callflow": [
{
"action": "dial",
"options": {
"destination": 12121218
},
"label": "+"
}
]
}
In the log, I can see:
<ActionController::Parameters {"callflow_json"=>"{\n \"callflow\": [\n {\n \"action\": \"dial\",\n \"options\": {\n \"destination\": 12121218\n },\n \"label\": \" \"\n }\n ]\n}", "controller"=>"callflows", "action"=>"manipulate", "callflow_id"=>"63"} permitted: false>
It appears that despite ensuring that the JSON in the textarea is correct and contains the "+", when it reaches the server, the "+" sign is not present and does not show up in the log at all.
I have experimented with using letters, "*", and "/", all of which work except for "+". What could be causing this issue in my code?
Thank you in advance for any assistance!