私はAjaxプログラミングが初めてで、Jquery ajaxを使用してデータをサーバーにフェッチし、テーブル形式で表示する必要があります。その場所にはラジオボタンのタイプを表示する必要があります。サーブレット固有のメソッドを呼び出す方法データを返す方法.json を使用する準備ができています。メソッドを呼び出す方法を教えてください。データを返す方法と、問題を解決するための提案が必要です
前もって感謝します。
$('#ajaxbutton').on('click',function(){
$.ajax({
type:"post",
url:"Db2",
data:{"labid",100},
sucess:function(){
alert("sucess");
}
});
});
サーブレットで
public class Db2 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws MalformedURLException, IOException {
doProcess(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws MalformedURLException, IOException {
doProcess(request, response);
}
public void doProcess(HttpServletRequest request,
HttpServletResponse response) throws MalformedURLException,
IOException {
Connection con;
PreparedStatement ps, ps1;
PrintWriter out = response.getWriter();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:oracle1", "system",
"sarath");
ps = con.prepareStatement("select trackid,location,to_char(mydate,'dd-mon-yyyy') from information where labid=100");
ResultSet rs = ps.executeQuery();
while (rs.next()) {
String location = rs.getString(2);
String track = rs.getString(1);
String myDate = rs.getString(3);
}
} catch (Exception e) {
out.println(e);
}
}
}// end of ServletB