如何在jsp中使用 jquery 的 ajax 功能


$(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() );
 }
本文作者:
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3