I am using $.ajax() to make a web service call from my client script. The data for this call is defined as follows.
data: "{ term: '" + request.term + "' }",
The problem is that request.term contains what the user typed into a text box. So what happens if it contains quotes or other unexpected characters?
Is there a function to escape any such characters so that the resulting JSON string will be correctly formed?