我有这个代码
<script type="text/javascript">
$(function () {
var selectedAmenities = "";
function amenitiesLog(message) {
$("<div/>").text(message).appendTo("#amenitiesLog");
$("<br/>").text("").appendTo("#amenitiesLog");
$("#amenitiesLog").scrollTop(0);
selectedAmenities = document.getElementById("amenitiesLog").innerHTML;
}
$("#Amenities").autocomplete({
//source: "/Results/GetAmenities",
source: function (request, callback) {
var url = "/Results/GetAmenities?selected=" + selectedAmenities + '&term=' + request.term;
$.getJSON(url, callback);
},
minLength: 3,
select: function (event, ui) {
if (ui.item != null)
amenitiesLog(ui.item.value);
}
});
});
</script>
这会导致生成并调用此 url
http://localhost:63320/Results/GetAmenities?selected=%3Cdiv%3EAir%20conditioning%3C/div%3E%3Cbr%3E&term=abc
我在 Firebug 中遇到的错误是这样的
A potentially dangerous Request.QueryString value was detected from the client (selected="<div>Air conditionin...").
解决办法是什么?
谢谢,
萨钦