2nd Code

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

$(document).

ready(function() {
2:
$("#btnTitleQuery").bind("click", function() {
3:
$("#query_results").empty();
4:
$("#query_results").append('<table id="ResultsTable"
class="BooksTable"><tr><th>BookNum</th><th>Title</th><th>Author</th></tr>');
5:
$.ajax({
6:
type: "POST",
7:
contentType: "application/json; charset=utf-8",
8:
url: "BookServices.asmx/GetBooksByTitle",
9:
data: '{ strTitle: "' + $("#txtTitle").val() + '" }',
10:
dataType: "json",
11:
success: function(msg) {
12:
var c = eval(msg.d);
13:
for (var i in c) {
14:
$("#ResultsTable tr:last").after("<tr><td>" + c[i][0] + "</td><td>" + c[i][1] +
"</td><td>" + c[i][2] + "</td></tr>");
15:
}
16:
}
17:
});
18:
})
19:
$("#btnAuthorQuery").bind("click", function() {
20:
$("#query_results").empty();
21:
$("#query_results").append('<table id="ResultsTable"
class="BooksTable"><tr><th>BookNum</th><th>Title</th><th>Author</th></tr>');
22:
$.ajax({
23:
type: "POST",
24:
contentType: "application/json; charset=utf-8",
25:
url: "BookServices.asmx/GetBooksByAuthor",
26:
data: '{ strAuthor: "' + $("#txtAuthor").val() + '" }',
27:
dataType: "json",
28:
success: function(msg) {
29:
var c = eval(msg.d);
30:
for (var i in c) {
31:
$("#ResultsTable tr:last").after("<tr><td>" + c[i][0] + "</td><td>" + c[i][1] +
"</td><td>" + c[i][2] + "</td></tr>");
32:
}
33:
}
34:
});
35:
})
36: });

You might also like