You can use encodeURIComponent().
It will escape all the characters that cannot occur verbatim in URLs:
var wysiwyg_clean = encodeURIComponent(wysiwyg);
In this example, the ampersand character &
will be replaced by the escape sequence %26
, which is valid in URLs.
More Related Contents:
- Send POST data using XMLHttpRequest
- IE10/IE11 Abort Post Ajax Request After Clearing Cache with error “Network Error 0x2ef3”
- jQuery Ajax File Upload
- Access Control Request Headers, is added to header in AJAX request with jQuery
- Add a “hook” to all AJAX requests on a page
- Upload file with Ajax XMLHttpRequest
- Why am I seeing an “origin is not allowed by Access-Control-Allow-Origin” error here? [duplicate]
- What is the cleanest way to get the progress of JQuery ajax request?
- POST data in JSON format
- Why am I seeing an “origin is not allowed by Access-Control-Allow-Origin” error here? [duplicate]
- Is onload equal to readyState==4 in XMLHttpRequest?
- What do the different readystates in XMLHttpRequest mean, and how can I use them?
- WebKit “Refused to set unsafe header ‘content-length'”
- Intercept fetch() API requests and responses in JavaScript
- How can I modify the XMLHttpRequest responsetext received by another function?
- XMLHttpRequest to Post HTML Form
- Get HTML code using JavaScript with a URL
- Is it possible for XHR HEAD requests to not follow redirects (301 302)
- Cross-Origin XMLHttpRequest in chrome extensions
- XMLHttpRequest 206 Partial Content
- Prompt file download with XMLHttpRequest
- Ajax – 500 Internal Server Error
- responseXML always null
- Microsoft Edge blocked cross-domain requests sent to IPs in same private network CIDR
- Reuse XMLHttpRequest object or create a new one?
- Differentiating Between an AJAX Call / Browser Request
- Adding X-CSRF-Token header globally to all instances of XMLHttpRequest();
- Is there any size limitation for ajax post?
- XmlHttpRequest.responseText while loading (readyState==3) in Chrome
- XMLHttpRequest testing in Jest