jQuery.parseJSON throws “Invalid JSON” error due to escaped single quote in JSON

后端 未结 7 955
挽巷
挽巷 2020-11-22 14:04

I’m making requests to my server using jQuery.post() and my server is returning JSON objects (like { \"var\": \"value\", ... }). However, if any of

相关标签:
7条回答
  • 2020-11-22 14:42

    When You are sending a single quote in a query

    empid = " T'via"
    empid =escape(empid)
    

    When You get the value including a single quote

    var xxx  = request.QueryString("empid")
    xxx= unscape(xxx)
    

    If you want to search/ insert the value which includes a single quote in a query xxx=Replace(empid,"'","''")

    0 讨论(0)
提交回复
热议问题