一部は、このような3ボタン・アンカーが含まれて押されたのデータのロードは、私のindex.htmlの
Index.htmlと
<a id="category1" href="html/auctionBay.html" class="portfolio-link" >
<a id="category2" href="html/auctionBay.html" class="portfolio-link" >
<a id="category3" href="html/auctionBay.html" class="portfolio-link" >
これらのボタンは、div要素が含まれているauctionBay.htmlに私をリダイレクト auctionBay.html
私は必要なもの<div id="result" class="container"></div>
、私が押されたものに応じてauctionBay.htmlに行くとし、上からボタンを押したときに、適切なテーブルからデータを印刷する(category1-3、あります)私のデータベースから '結果' div(それはdivにあることが重要です)。 私は現在auction.html負荷がAJAX呼び出し
var j = jQuery.noConflict();
function myFunction() {
j.ajax({
type : 'GET',
url : '../auctionsDisplay',
success : function(data) {
j("#result").html(data);
}
});
}
を使用しますが、私は手動でカテゴリを指定した場合のみ動作時に静的にこれを行うことができますサーブレットを持っている。(骨董品=例えばカテゴリ1)
AuctionDisplay。 Javaの
public class AuctionsDisplay extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String result = "";
try {
Connection con = DBConnection.getCon();
String category = "antiques";
String query = "select id, name, price from " + category;
PreparedStatement ps = con.prepareStatement(query);
ResultSet rs = ps.executeQuery();
int i;
result = "";
boolean flag = rs.next();
while (flag) {
result += "<div class='container'><div class='row'><h1 id='antiques' class='category'>Antiques</h1></div><div class='row'>";
i = 0;
while (i < 4 && flag) {
ps = con.prepareStatement("select highestBidder, ends from auctions where itemId=?");
ps.setString(1, rs.getString("id"));
ResultSet rs2 = ps.executeQuery();
rs2.next();
String price = rs.getString("price");
if (rs2.getString("highestBidder") != null)
price = rs2.getString("highestBidder");
result += "<div class='col-md-3' portfolio-item>";
result += "<div class='w3-container w3-hover-shadow w3-center'>" + "<h2>" + rs.getString("name")
+ "</h2><div class='w3-card-20' style='width:100%'>"
+ "<input id='2' type='image' src='../img/portfolio/w3.jpg' data-toggle='modal' "
+ "data-target='#MoreInfo'style='width:90%;'>"
+ "<div class='w3-container w3-center responsive'>"
+ "<p style='padding:5px;'>Highest Bid: " + price + "\u20ac <br> " + "Ends at: "
+ rs2.getString("ends") + "<p></div></div></div></div>";
flag = rs.next();
i++;
}
result += "</div></div>";
}
} catch (Exception e) {
e.printStackTrace();
}
out.println(result);
}
私はアヤックスは、Get-POSTリクエストは、Javascript(無PHPください)、jqueryの理解、ので、どのように私は私が望むものを達成することができますか?それは簡単ですが、それは私を混乱させます
を助けた場合は、使用のURLクエリだけで、他のGET – charlietfl