I have a locale variable that can be en, fr, or es.
I have to send an AJAX request, with the locale as the key of the data parameter.
let locale = "en";
let name = "example";
$.ajax({
url: "/path",
method: "PUT",
data: {characteristic: {`${locale}`: name}},
success: function(){},
error: function(){}
})
I tried to use ES6's string interpolation, but it raises a syntax error. How can I do this ?
I'd like to get, depending on the locale:
{en: "example"}
{fr: "example"}
{es: "example"}