Download the Assignment 8 code from GitHub. (Here\'s the link to get the informa
ID: 3594553 • Letter: D
Question
Download the Assignment 8 code from GitHub. (Here's the link to get the information mentioned; https://github.com/DonnieSantos/IT-2320/tree/master/Week%208%20-%20Introduction%20to%20AJAX/Assignment%208/Assignment8). The solution is already set up with a front and back end to do most of the work. The back end has a small database of Cleveland Cavaliers players, and if provided with a player number, will respond with the player’s name. The tech specs of the back end are provided and documented in the Requirements folder. The tech specs, along with a screenshot example using the Advanced REST client, clearly demonstrate how to format a JSON request, and receive a JSON response. Your assignment is to use JQuery to capture the player number entered in the textbox on the screen, and when the user clicks the “Get Player Information”, use the JQuery ajax method to retrieve the player’s name upon receiving the response from the server. If the number entered does not exist in the database, you will receive an error message. Either way, you will indicate the player’s name and number, or the error message, in the red output box on the screen. (attached is a copy of the data in the back end database, but you should NOT have to look at any of the C# back end code)
I am using Visual Studio 2017 so if I can, could you get back to me using that software. Thank you in advance.
Explanation / Answer
The following is the code for playerDetails.jsp, which expects player number and returns name of the player in the form of JSON
<% @ page import =”java.sql.*” contentType =”text/ json”%>
<%
String playerNumber = request.getParameter(“PlayerNumber”);
Class.forName(“oracle.jdbc.driver.OracleDriver”);
Connection con= DriverManager.getConnection(“jdbc:oracle:thin:@localhost:1521:XE”,”hr”,”hr”);
Statement st= con.createStatement();
ResultSet rs= st.executeQuery(“select name from Player where PlayerNumber=”+ playerNumber);
If(rs.next())
{
out.println(“name”);
out.println(“”+rs.getString(1)+””);
}
Else
{
Out.println(“{” error”:”Employee id not found !”}”);
}
rs.close();
st.close();
con.close();
%>
Following is the JQuery Ajax file:
<html>
<head>
<title>AJAX and JSON with JQuery</title>
<script language= “javascript” src= “jquery-1.2.6.js”></script>
<script language= “javascript”>
function getPlayerInformation()
{
}
function displayResult(data)
{
if(data.error)
{
$(“#playerName”).val(“ ”);
Alert(data.error);
}
Else
{
$(“#playerName”.val(data.name));
}
}
</script>
</head>
<body>
<form id=”form1”>
<h2> Player Information </h2>
<table>
<tr>
<td> PlayerNumber </td>
<td> <input type =”int” id= “playernumber” size=”10”/> <input type=”button” value=”GetPlayerInformation” /></td>
</tr>
<tr>
<td> PlayerName </td>
<td><input type = “text” id=”name” /> </td>
</tr>
</table>
</form>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.