I am having a problem with special character in javascript. I have a form with a input text that has the following string:
10/10/2010
after a form.serialize(); I get this string as
10%2F10%2F2010
The '/' character is converted to its ASCII code %2F.
I would be able to convert that using String.fromCharCode(ascii_code)
but I have many inputs in my form so these string is somenthing like:
var=14&var=10%2F10%2F2010&var=10%2F10%2F2010&var=10%2F10%2F2010
Just an example to state that I would have to go through this string ("manually") and find those value and convert it.
Is there any easy way to perform that conversion? Strange thing because I did not have that problem before, I am not sure why this is happening now.
I am having a problem with special character in javascript. I have a form with a input text that has the following string:
10/10/2010
after a form.serialize(); I get this string as
10%2F10%2F2010
The '/' character is converted to its ASCII code %2F.
I would be able to convert that using String.fromCharCode(ascii_code)
but I have many inputs in my form so these string is somenthing like:
var=14&var=10%2F10%2F2010&var=10%2F10%2F2010&var=10%2F10%2F2010
Just an example to state that I would have to go through this string ("manually") and find those value and convert it.
Is there any easy way to perform that conversion? Strange thing because I did not have that problem before, I am not sure why this is happening now.
Share Improve this question asked Jan 31, 2013 at 16:07 Guilherme LongoGuilherme Longo 2,3087 gold badges47 silver badges65 bronze badges 1-
1
decodeURIComponent("10%2F10%2F2010")
– Yury Tarabanko Commented Jan 31, 2013 at 16:10
1 Answer
Reset to default 6I happens that way because that's how it's meant to be:
The .serialize() method creates a text string in standard URL-encoded notation. It operates on a jQuery object representing a set of form elements.
As far as I know, there's no native jQuery function to unserialize but your post suggests you already got that and are only stuck in the URL-encoded strings:
decodeURIComponent(encodedURI)
Decodes a Uniform Resource Identifier (URI) ponent previously created by encodeURIComponent or by a similar routine.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745109133a4611740.html
评论列表(0条)