我抓到这家伙了。他把一串字串解码成可读的。
decodeURIComponent("Invalid Ticker Name \u0027t\u0027 at line: 3")
"Invalid Ticker Name 't' at line: 3"现在看看这个。它告诉我们这个字符串(数组项)的源实际上是一个字符串。
typeof decodeURIComponent(errorsArr[i])
"string"但是,当我尝试解码数组项时,它就是不起作用。
decodeURIComponent(errorsArr[i])
"Invalid Ticker Name \u0027t\u0027 at line: 3"该怎么办呢?
发布于 2012-08-08 23:49:24
问题已经解决了。
正如代码中所写的
// If the document was sent as 'application/javascript' or
// 'text/javascript', then the browser wraps the text in a <pre>
// tag and performs html encoding on the contents. In this case,
// we need to pull the original text content from the text node's
// nodeValue property to retrieve the unmangled content.
// Note that IE6 only understands text/html我已经开始以html/text的形式提供文件,这就解决了这个问题。
发布于 2012-08-08 04:04:29
我知道那是什么。您的字符串中有一个文字\u0027。您可以在浏览器中使用以下命令验证此行为:
javascript:alert("\u0027");alert("\\u0027");当您将其输入为:
Invalid Ticker Name \u0027t\u0027 at line: 3它正在替换unicode字符。为什么不能使用%27
https://stackoverflow.com/questions/11853145
复制相似问题