我遇到了SQL问题,我已将其归结为:
//method to add script
function updateTags(response) {
let htmlFragment = document.createDocumentFragment();
let tempNode = document.createElement('div');
tempNode.innerHTML = response;
htmlFragment.appendChild(tempNode.firstChild);
let scriptTag = htmlFragment.querySelector('script');
scriptTag.setAttribute('class', 'removeables');
return htmlFragment;
}
$(document).ready(function() {
var response = '<script>alert("hello")<\/script>';
var fragment = updateTags(response);
$(document.body).append(fragment);
$("#delete").on('click', function() {
$('.removeables').remove();
});
});
抛出错误<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<div id="content">
</div>
<button id="delete">remove</button>
</body>
</html>
为什么会抛出此错误,以及如何解决?
答案 0 :(得分:2)
这个更简单的表达式(相当于你的表达式)给出了同样的错误:
if 5.5 = '' select 0 else select 1
您正在将varchar与数字类型进行比较,如错误所示。
您可以CAST
表达式匹配类型:
if CAST(isnull(5.5,'') AS VARCHAR) = isnull(null,'') select 0 else select 1