jQuery中的转义字符
我在谷歌上搜索过stackoverflow的答案,但还没有找到合适的答案。我的输入通常包含jQuery中的转义字符,jquery,Jquery,我在谷歌上搜索过stackoverflow的答案,但还没有找到合适的答案。我的输入通常包含&(与号)和@,因此我需要转义变量CN99,如何使用jquery实现这一点 $("#CompanyNameFilter").focus(function() { var CN99 = $("#CompanyNameFilter").val(); $.ajax({ url: "clients.php?companyname=" + CN99, dataType
&
(与号)和@
,因此我需要转义变量CN99,如何使用jquery实现这一点
$("#CompanyNameFilter").focus(function() {
var CN99 = $("#CompanyNameFilter").val();
$.ajax({
url: "clients.php?companyname=" + CN99,
dataType: "html",
success: function(html) {
var div = $("#companyList", $(html)).addClass("done");
$("#companyList").html(div);
}
});
});
您应该使用
ajax
的data
选项传递url参数
$("#CompanyNameFilter").focus(function() {
var CN99 = $("#CompanyNameFilter").val();
$.ajax({
url: 'clients.php',
data: {companyname: CN99},
type: 'get',
dataType: "html",
success: function(html) {
var div = $("#companyList", $(html)).addClass("done");
$("#companyList").html(div);
}
});
});
jQuery将以这种方式处理编码您是否检查了这个?