您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

在ajax调用中访问函数外部变量的问题

在ajax调用中访问函数外部变量的问题

试试这个:

$(document).ready(function(){
    // This function get the search results from Solr server 
    $("#submit").click(function(){
        var query=getquerystring() ; //get the query string entered by user
        var newquery=query;
        $.getJSON("http://192.168.1.9:8983/solr/db/select/?wt=json&&start=0&rows=100&q="+query+"&json.wrf=?", function(result){
            if(result.response.numFound==0)
            {
                $.ajax({
                    url: "http://192.168.1.9:8983/solr/db/select/?wt=json&&start=0&rows=100&q="+query+"&spellcheck=true&json.wrf=?",
                    async:false,
                    dataType: 'json',
                    success: function(json){
                        $.each(json.spellcheck.suggestions, function(i,item){
                            newquery=item.suggestion;
                        }); 
                        $.getJSON("http://192.168.1.9:8983/solr/db/select/?wt=json&&start=0&rows=20&q="+newquery+"&sort=price asc&hl=true&hl.fl=description&hl.usePhraseHighlighter=true&json.wrf=?", function(result){
                    }

                    });
                }
            }else{

                $.getJSON("http://192.168.1.9:8983/solr/db/select/?wt=json&&start=0&rows=20&q="+newquery+"&sort=price asc&hl=true&hl.fl=description&hl.usePhraseHighlighter=true&json.wrf=?", function(result){

            }
其他 2022/1/1 18:13:47 有596人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶