开发者

Why does Jquery ajax add slashes to String? [duplicate]

开发者 https://www.devze.com 2023-01-07 21:01 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicate: jQuery: How to stop AJAX function escaping JSON string used to POST data
This question already has answers here: Closed 12 years ago.

Possible Duplicate:

jQuery: How to stop AJAX function escaping JSON string used to POST data

I make a jQUERY ajax call to send and save to data.When I send Google's Dog string, I receive Google\'s Dog . What is the reason of this . And what is the best way yo avoid this. I do not want to use stripslashes function because this removes all backslashes

$.ajax({
  type: "POST",
  url: 'http://example.com/api/save',
  data: {
    data: userArray,
  },
  dataType: 'json',
  success: function(response) {
  }
});

user开发者_开发知识库Array is an array which has user's information


Those slashes are escaping the special characters. Basically its telling javascript to treat that character as a normal string character instead of something 'special'. Click the link for more examples.


Already answered. jQuery: How to stop AJAX function escaping JSON string used to POST data

0

精彩评论

暂无评论...
验证码 换一张
取 消