我的网页上有这个代码。它显示了推荐信。但是我得到了Uncaught TypeError的奇怪错误:对象[object Object]的属性'$'不是函数。
关于堆栈溢出的一些类似问题建议使用jQuery而不是$,但即便在那里工作。
代码是这个
<script src="./Aero Travel & Tours_files/jquery-1.9.0.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="./Aero Travel & Tours_files/jquery.bxslider.min.js"></script>
<script>
var bx= $.noConflict(true);
bx(document).ready(function() {
bx('.testimonials-slider').bxSlider({
slideWidth: 800,
minSlides: 1,
maxSlides: 1,
slideMargin: 32,
auto: true,
autoControls: true
})});
$(document).ready(function () {
$.ajax({
type: "POST",
url: "/Web/Common/API/WebService1.asmx/GetTestimonials",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
success: function (data) {
var json = $.parseJSON(data.d)
var testimonial = "";
$.each(json, function (i, obj) {
if (i == 0 || i + 1 == json.length) {
testimonial += "<div class='slide bx-clone'>";
}
else {
testimonial += "<div class='slide'>";
}
testimonial += " <div class='testimonials-carousel-context'>";
testimonial += " <div class='testimonials-name' style='font-weight: bold;'>" + obj.Signature + "</div>";
testimonial += " <div class='testimonials-carousel-content'>" + obj.Description + "</div>";
testimonial += " </div>";
testimonial += "</div>";
testimonial += "<br/>";
});
$('#testimonials').html(testimonial);
}, //success
error: function (jqXHR, testStatus, errorThrown) {
alert("The following error occured while retrieving the project information: " + testStatus + " " + errorThrown);
} //error
});
});
</script>
答案 0 :(得分:1)
如果只是冲突问题,请尝试更改document.ready函数,如下所示:
jQuery(document).ready(function($) {
// inside you can now use the $ as before.
});
答案 1 :(得分:0)
var bx= $.noConflict(true);
在您的代码中,'$'符号应替换为'bx'