search

Home  >  Q&A  >  body text

javascript - There are single quotes in interface parameters in Ajax, and the characters after the single quotes are lost

var name = "name:Fu'an"
$.ajax({
  dataType: 'text',
  url: "get_top_count?query=" + name

You can see through the browser packet capture:
There is only this name:Fu

during transmission

So, now I want to ask how to deal with this single quote! ~
Thank you

阿神阿神2724 days ago550

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-06-12 09:34:01

    escape("name:'a'")
    "name%3A%27a%27"

    reply
    0
  • Cancelreply