I'm using a ajax
request, which returns me a json, from a .php
page, with the name of a city of Mato Grosso do Sul named: Antônio João .
The error is javascript. Which reads as follows:
Some functions in javascript do not allow empty spaces between characters. An example, in my case, was add()
. I'm using to add a classList
var nomediv = 'Antônio João';
element.classList.add(nomediv);
The element.classList returns a DOMTokenList
of the element's class attributes. element is a DOMTokenList that represents the class attribute of the elementNodeReference. Therefore, it is known that as a rule, não é permitido espaços para compor o nome de uma classe
. And to solve the error was implementing a simple REGEX :
var nomediv = 'Antônio João';
element.classList.add(nomediv.value.replace(/\s/g, '') );