• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

JS/jQuery encode URL for getJSON

Hey Guys, I have a string with special characters that need to be passed via getJSON

Code:
$.getJSON("https://me.com/login.cfc?method=login&email=" + email + "&password=" + password,function(result){});

Basically, the 'password' variable has special characters in it. But I have other functions that may have special characters, so I need to know a best practice on how to deal with it.

What's the best way to encode that?
 
You want to use the method encodeURIComponent() on the string you want to encode.

Thanks, I was about to do that, but saw this method

Code:
								$.getJSON(
									'http://my.com/login.cfc',
										{
										method : 'login',
										email : email,
										password : password,
										},
										function(result){

which seems to work!
 
Thanks, I was about to do that, but saw this method

Code:
								$.getJSON(
									'http://my.com/login.cfc',
										{
										method : 'login',
										email : email,
										password : password,
										},
										function(result){

which seems to work!

I imagine they are encoding it within the implementation of that function.
 
Back
Top