I'm developing an application that uses PHP + AJAX and I came across a boring problem. AJAX only recognizes the function if it is like this:
onclick="remover_musica_ftp('0','Deposito de bebida'
);"
I'm using PHP to "print" these values in the browser like this:
echo "<a href='#excluir' class='button icon-trash' onclick=remover_musica_ftp('0','".$nomes."'); title='Excluir'></a>";
I have to use php because I'm doing foreach
.
So far so good, the problem is that when the word contains spaces, ajax simply does not respond, because the code would need to be as in the first example, but when I add the "
tag automatically PHP becomes invalid, since the even echo
started with a quotation mark.
Does anyone know how to proceed in this case?
If I open the echo with a '
it will give error in the same way, since I would need to invert the onclick of ajax that would not allow '
in the functions.
Give me a suggestion!