JavaScript doesn't run away \ character?

I am creating a query for YQL and I am facing a dumb problem. I will not embed the entire query as there is no need, only the part that I came across is with:

var query = encodeURI("... and xpath='//div[@class=\\'body bodySign\\']/p' ...")';

As you can see, I added two characters \, this is necessary for the actual request. I use multiple queries and I need to double the esacpe character 'so that they are correctly parsed in YQL.

But JavaScript escapes the character \. It doesn't matter how much \I add (for "escape" to the next character \). I still leave only one \in my request.

How to save multiple characters \without escaping from each other?

thank

+5
source share
1

var query = encodeURI("... and xpath='//div[@class=\\\\'body bodySign\\\\']/p' ...")';

, F12 console.log("\\\\").

+1

All Articles