0

hi, thank you for helping in advanced

i faced some punctuation problem during i using ajax
I used ajax with Get Method to pass some value from textarea
to update the database.My problem is:

example: "Hi, I'm Jane~"

database updated : "Hi, I'm Jane~"

but the response.text of ajax give me return in this
"Hi, I\'m Jane~"

"\" ??? where did it come from? how to solve it?
Anyone help please!

Edited by Nybuler: n/a

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by matricol
0

I assume you're using a PHP backend? If so try stripslashes() before returning the data back via the ajax request.

Possible cause (if using a PHP backend) is multiple escaping, for example mysql_real_escape_string() and addslashes().

If this is just simply a Javascript problem, you could try just removing the slash

var.replace('\', '');

However I'd be weary of this solution, as if your returning anything that has (or needs) a legitiment \ then this would break your code.

Best of luck finding your solution.

You could perhaps help other users more (if neither of these are an appropriate solution) by elaborating more on the process of what you're doing, and where it's going wrong.

Edited by MrDJK: n/a

0

Dear MrDJK for telling me what is this!

i get it work already...:D

The solution is

Paste this function in my javascript
function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\0/g,'\0');
str=str.replace(/\\\\/g,'\\');
return str;
}

and stripsplashes(response.Text) in ajax

and Wallah ! Success! :twisted:

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.