Javascript:decodeURIComponent 拒绝工作
Javascript: decodeURIComponent refuses to work
我得到了这个人。他将字符串解码为可读字符串。
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"
怎么办?
我知道它是什么。 字符串中包含文字'u0027
。 您可以使用以下命令在浏览器中验证此行为:
javascript:alert("'u0027");alert("''u0027");
当您输入它时:
Invalid Ticker Name 'u0027t'u0027 at line: 3
它替换了 unicode 字符。 为什么不能使用%27
?
问题已解决。
如代码中所写
// 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/文本提供,这解决了问题。
相关文章:
- Javascript:selenium Web驱动程序isDisplayed()不工作
- jQuery UI自动完成突然停止工作
- AngularJS UI路由器不能像ng路由器那样工作
- Javascript:decodeURIComponent 拒绝工作
- if 和 else-if 语句拒绝在 jQuery 的 AJAX 函数中工作
- Jquery Ajax在本地主机上工作,但拒绝在服务器上工作
- Javascript拒绝工作
- Javascript拒绝工作
- UIKit (getuikit) 滑块组件拒绝工作
- JavaScript 警报拒绝在表单验证中工作
- Jsonp请求拒绝工作
- Onclick事件拒绝工作
- 当action使用promise时,indexOf拒绝在值突变中工作
- 折线拒绝显示在IE8上,在其他地方工作
- 添加到购物车按钮不工作-拒绝获得不安全的标题"X-JSON"
- Admin页面不能在orgfree中工作,拒绝用户'root'@'localhost'
- jquery美元.Post被服务器拒绝,但是$(form).submit()工作
- AngularJS延期.拒绝不工作,但$q.拒绝工作
- Pnotify拒绝工作
- 数据表中的事件监听器拒绝工作