Javascript 发布jQuery表单时如何不重新加载ASP页面?

Javascript 发布jQuery表单时如何不重新加载ASP页面?,javascript,jquery,asp-classic,Javascript,Jquery,Asp Classic,请容忍我,我完全是个新手 我想做什么? 我正在尝试从输入中筛选课程列表 我的环境是什么? 我在ASP编码的CMS中工作,我没有访问服务器页面的权限。 我只能在页面的“模块”中插入一些代码,并在FTP上上载文件。 这些页面是XHTML1.0过渡版,我对此无能为力 我的问题是: 这段代码在本地和上运行,但当我将其插入沙箱时,它所做的只是重新加载页面 这是我插入的HTML <script type="text/javascript" src="//code.jquery.com/jquery-l

请容忍我,我完全是个新手

我想做什么? 我正在尝试从输入中筛选课程列表

我的环境是什么? 我在ASP编码的CMS中工作,我没有访问服务器页面的权限。 我只能在页面的“模块”中插入一些代码,并在FTP上上载文件。 这些页面是XHTML1.0过渡版,我对此无能为力

我的问题是: 这段代码在本地和上运行,但当我将其插入沙箱时,它所做的只是重新加载页面

这是我插入的HTML

<script type="text/javascript" src="//code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="js/searchCatalog.js"></script>
<link rel="stylesheet" type="text/css" href="css/searchCatalog.css">
<form id="live-search" action="" class="styled" method="post">
<input type="text" class="search-field" id="filter" placeholder="What course are you looking for?" value="" />
<span id="filter-count"></span>
</form>
<ul class="courselist">
<li><a href="http://stackoverflow.com" target="_blank">English course 1</a></li>
<li><a href="http://stackoverflow.com" target="_blank">English course 2</a></li>
<li><a href="http://stackoverflow.com" target="_blank">Spanish course 1</a></li>
<li><a href="http://stackoverflow.com" target="_blank">Spanish course 2</a></li>
</ul>

这是我上传的JS

$(document).ready(function () {
    $('#filter').keypress(function (e) {
        if (e.which == 13) {
            // Hide the number of courses when nothing is entered in the search field
            if ($(this).val() == '') {
                $('#filter-count').hide();
            } else {
                $('#filter-count').show();
            }
            // Retrieve the input field text and reset the count to zero
            var filter = $(this).val(), count = 0;

            // Loop through the course list
            $(".courselist li").each(function () {

                // If the list item does not contain the text phrase fade it out
                if ($(this).text().search(new RegExp(filter, "i")) < 0) {
                    $(this).fadeOut();

                    // Show the list item if the phrase matches and increase the count by 1
                } else {
                    $(this).show();
                    count++;
                }
            });
            e.preventDefault();
            // Update the count
            var numberItems = count;
            $("#filter-count").text("Number of courses related to your search : " + count);
        }
    });
});
$(文档).ready(函数(){
$(“#过滤器”)。按键(功能(e){
如果(e.which==13){
//在搜索字段中未输入任何内容时隐藏课程数
if($(this.val()=''){
$(“#过滤器计数”).hide();
}否则{
$(“#过滤器计数”).show();
}
//检索输入字段文本并将计数重置为零
var filter=$(this).val(),count=0;
//循环浏览课程列表
$(“.courselist li”)。每个(函数(){
//如果列表项不包含文本短语,请将其淡出
if($(this.text().search)(新的RegExp(filter,“i”))<0){
$(this.fadeOut();
//如果短语匹配,则显示列表项并将计数增加1
}否则{
$(this.show();
计数++;
}
});
e、 预防默认值();
//更新计数
var numberItems=计数;
$(“#筛选计数”).text(“与搜索相关的课程数:+count”);
}
});
});

非常感谢您的帮助。

将脚本src更改为以下内容

<script type="text/javascript" src="//code.jquery.com/jquery-latest.min.js"></script>
<script src="//malsup.github.io/jquery.blockUI.js"></script>


检查您的控制台中是否有error@A.Wolff感谢您的回复,但我不知道如何做…我说的是浏览器控制台,在浏览器中按F12,刷新页面并检查是否有错误消息[阻止]“”处的页面是通过HTTPS加载的,但运行的是来自“”的不安全内容:此内容也应通过HTTPS加载。[阻止]通过HTTPS加载了“”处的页面,但运行了来自“”的不安全内容:此内容也应通过HTTPS加载。@Aymericm,如果删除http:部分并将其保留在//处,则脚本应可以正常加载。但是,我警告不要引用最新的jquery版本,通常您希望针对特定的版本。Thx mituw16适用于//code.jquery.com/jquery-latest.min.js,但正如@a.Wolff所说,它不适用于//malsup.github.io/jquery.blockUI.js。没关系,我只是删除了最新版本。