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!

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.

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:

use ascicode for quote

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.