jquery ajax调用后台方法
jquery ajax怎么调用后台方法,不用struts和servlet实现,只写一个类.-----------------------------------------------------------------
jsp调用ajax方法代码如下:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'jspAjax.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" src="zTree/jquery-1.4.2.js"></script>
</head>
<body>
<script type="text/javascript">
function getAjax(){
$.ajax({
type: "POST",
url: "XXXXXX",
data: "",
success: function(msg){
alert("调用成功");
}
});
}
</script>
<form action="servlet/test" method="get">
<table>
<tr>
<td><input type="submit"/></td>
<input type="button" name="button2" id="Ajax" onClick="getAjax()" value="delete"/>
</tr>
</table>
</form>
</body>
</html>
-------------------------------------------------------------------------
java类如下:
package com;
public class javaAjax {
public String getDemo(){
System.out.println("javaAjax");
return "1";
}
}
请问ajax中的url应该怎么调用该类的方法,能不能实现,请各位童鞋帮忙,在线等待。。。。