如何在“内容”页面中访问“脚本”功能 [英] How do I access the Script function in Content pages

查看:88
本文介绍了如何在“内容”页面中访问“脚本”功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在母版页中有一个SearchText文本框。我使用脚本代码搜索建议

我的代码是

i've a "SearchText" Textbox in master page. I used the Script code for search suggestion
my code is

<script type="text/javascript">
            $(document).ready(function () {

                $('#<%=SearchText.ClientID%>').autocomplete({
                    source: function (request, response) {
                        $.ajax({
                            url: "SearchSuggestions.asmx/GetSuggestions",
                            data: "{ 'searchValue': '" + request.term + "' }",
                            type: "POST",
                            dataType: "json",
                            contentType: "application/json;charset=utf-8",
                            success: function (result) {
                                response(result.d);
                            },
                            error: function (result) {
                                alert('There is a problem processing your request');
                            }

                        });
                    }
                });
            });



它在Default.aspx上运行正常。但在其他内容页面上,此代码似乎无效。


it works fine on Default.aspx. but on other content pages this code does not seems working.

推荐答案

document )。ready(< span class =code-keyword> function (){
(document).ready(function () {


' #<%= SearchText.ClientID%>')。autocomplete({
source: function (request,response ){
('#<%=SearchText.ClientID%>').autocomplete({ source: function (request, response) {


.ajax({
url: SearchSuggestions。 asmx / GetSuggestions
data: {'searchValue':' + request.term + '}
类型: POST
dataType: json
contentType: application / json; charset = utf-8
成功: function (结果){
response(result.d);
},
错误: function (结果){
alert(' 处理您的请求时出现问题');
}

});
}
});
});
.ajax({ url: "SearchSuggestions.asmx/GetSuggestions", data: "{ 'searchValue': '" + request.term + "' }", type: "POST", dataType: "json", contentType: "application/json;charset=utf-8", success: function (result) { response(result.d); }, error: function (result) { alert('There is a problem processing your request'); } }); } }); });



它在Default.aspx上运行正常。但在其他内容页面上,此代码似乎不起作用。


it works fine on Default.aspx. but on other content pages this code does not seems working.


这篇关于如何在“内容”页面中访问“脚本”功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆