主题: 在JSP中使用jquery的ajax功能
精华帖 (0)   良好帖 (0)   新手帖(0)   垃圾帖 (0)      收藏
  • machiatto 我现在不在线,你找我吗?
  • 显示用户头像
  • 昵称:machiatto
  • 专家等级:中级程序员
  • 专家分:2119
  • 可用分等级:小地主
  • 精华:0
  • 帖子数:3327
  • 结帖率: 74%
  • 注册时间:2009-06-28 19:08:35
发表于 2009-07-15 15:58:57
楼主

 在JSP中使用jquery的ajax功能

      [关键字: jsp中使用query,ajax功能]

 jquery  在 jsp 中的应用 源代码 和 演示
$(document).ready(function() {   
    $("a").click(function() {
        $("#decimal").val('这是一个例子');
        $("#inputtext").val('控制text');

    });

/*
    $("a").click(function() {
        alert("Hello world!");
    });
*/
   

});  

function convertToDecimal(){
   $.ajax({
        type: "GET",
        url: "/jqueryjsp/response",
        data: "key=" + $("#key").val(),
        dataType: "html",
        success: function(xml){
        //alert( "keypress code: " + $("key",xml).text() );
/*
        var decimal = document.getElementById('decimal');
        decimal.value = $("key",xml).text();
        //等价于上面的代码。
        $("#decimal").val($("key",xml).text());
*/
        $("#decimal").val($("key",xml).text());

        $("#rating").html("按键代码:" + $("key",xml).text());
        }   
   })
    clear();
  }

  function clear(){
    var key = document.getElementById("key");
  
    key.value="";
    // alert( "keypress code: " + $(this).html() );
  }


jquery 在 php 中使用的例子很多,但是没有 jsp 的,
我修改了ajax  on java 中的第三章的例子,应用了jquery实现了ajax
源代码 在附件中

使用方法
将压缩包中的文件放到
在tomcat 中webapps中。


快速回复主题
您还未登录,不能回复帖子
phome.asia   程序员之家论坛
程序员之家 版权所有 Copyright 2004-2009 All Rights Reserved©2009 京 ICP 备 05027197 号 网站地图 关于我们 联系我们