Arbu Posted July 1, 2020 Report Share Posted July 1, 2020 I'm sending some information to the server with AJAX: function saveFileToAccount(filename){ /** [Storing JSON representations of the canvas] */ var data = formattedJSON(); /** [Store preview of transaction diagram] */ var image = canvas.toSVG(); var xmlhttp = new XMLHttpRequest(); var sendstring = "filename=" + filename + "&json=" + data + "&image=" + image; xmlhttp.open("POST", "includes/process_save.php", true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.send(sendstring); } This goes into an SQL database and I get it back with php when a new page is opened. But the data comes back truncated at the first ampersand that it contains. How do I fix this? I suppose I could convert all the ampersands into a little used character before saving the data and then convert them back when it comes back, but that doesn't seem very satisfactory. Is there a proper way to sort this out? Thanks. Link to comment Share on other sites More sharing options...
Arbu Posted July 1, 2020 Author Report Share Posted July 1, 2020 var data = encodeURIComponent(formattedJSON()); seems to fix the problem. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now