0
The .serialize(); takes all form information, but with different accents
ex: LOAF stays P%C3%83O , when I test the app on localhost the accents work right but when hospedo gets like this BREAD ???
I made this example
<form name='meuForm' method='post' action='action' id='formStr'>
<input type='text' name='str1' value='palhação' id='str1' />
<input type='text' name='str2' value='Fábio' id='str2' />
<input type='submit' id='teste' valiue='testar' /> </form>
$( "form" ).on( "submit", function( e ) { e.preventDefault(); var str1 = $('#str1').val(); var formSerializado = $(this).serialize(); console.log( 'str1 = '+str1+', formSerializado = '+ formSerializado ); });
On the.log() console is
str1 = palhação, formSerializado = str1=palha%C3%A7%C3%A3o&str2=F%C3%A1bio
and I would like to understand why when I have the value of var str1 the value is right and when serializo becomes strange, I believe it is the same reason that my app is giving accentuation problem.
To avoid problem in the use site <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
on all pages.
There is a way to code when serializing?
Straw%C3%A7%C3%A3o&str2=F%C3%A1bio is correct in UTF-8. The problem seems to be when showing the data. Remember to set the charset on the goal too:
<meta charset="utf-8">
to be sure of what is happening.– Bacco
@Bacco - That’s right. It is only necessary to treat this string. in PHP can be done with
utf8_decode()
.– Franchesco
I am using Javaservlets and in Insert the letter Á stays  â â
– Fabio Macedo
make sure you are not decoding the string twice in the same code by mistake.
– Bacco