My string for my AJAX GET request looks like the following:
return domain + '?x=' + JSON.stringify(x)
Do need to use encodeUriComponent
to make the URI valid? For example:
return domain + '?x=' + encodeURIComponent(JSON.stringify(x))
This is what I understand from reading some posts and answers (please feel free to correct me)
JSON - JavaScript Object Notation
Regardless to JSON:
I used these answers for my summary:
Difference between JSON.stringify and JSON.parse
difference between escape, encodeuri, encodeURIComponent
JSON.stringify
doesn't escape characters, it just returns you string representation and as you are using it in url you need to escape it using encodeURIComponent
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With