为什么decodeURIComponent('%')会锁定我的浏览器? [英] Why does decodeURIComponent('%') lock up my browser?
本文介绍了为什么decodeURIComponent('%')会锁定我的浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是用AJAX测试了一些东西,我发现如果我发出警报就会成功
I was just testing something with AJAX and I found that on success if I alert
alert(decodeURI('%'));
或
alert(encodeURIComponent('%'));
浏览器错误输出以下代码。
the browser errors out with the following code.
$.ajax({
type: "POST",
url: "some.php",
data: "",
success: function(html){
alert(decodeURIComponent('%'));
// alert(decodeURI('%'));
}
});
如果我使用任何其他字符串它就可以正常工作。
这是什么东西我错过了吗?
If I use any other string it works just fine.
Is it something that I missed?
推荐答案
从控制台尝试时的Chrome barfs。它给出了一个URIError:URI格式错误。 %是一个转义字符,它不能单独使用。
Chrome barfs when trying from the console. It gives an URIError: URI malformed. The % is an escape character, it can't be on its own.
这篇关于为什么decodeURIComponent('%')会锁定我的浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文