ajax写好了,后台out.print();拿不到数据,给看看

想实现这个效果::http://www.helloweba.com/demo...

前台的ajax:

function getdata(){

    var num = $("#cur_num").val();

    $.ajax({

        url: 'updateCountWx.action',

        type: 'POST',

        dataType: "json",

        data:{'total':num},

        cache: false,

        timeout: 10000,

        error: function(){},

        success: function(data){

            show_num(jsonb.counttest);

        }

       });

}


我现在不明白。后台应该怎么写才能和这个前台的ajax对应起来。


    JSONArray jsonas=new JSONArray();

    JSONObject jsonb=new JSONObject();

ps=conn.prepareStatement("select count(*) count from text");


     resl=ps.executeQuery();//返回查询的数量。

     if(resl.next()){

         counttest=resl.getInt("count");

         jsonb.put("counttest", counttest);

        

        }

out.print(jsonb);

这样写不对。应该怎么改


POPMUISE
浏览 880回答 2
2回答

侃侃无极

out 中设置content-type为application/jsonshow_num(jsonb.counttest) 改为show_num(data.counttest)
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java