I'm currently learning web design through a co-op position at a company. Unfortunately, the department I am placed in lacks experts in web design. Nevertheless, I am determined to make it work.
My current project involves creating a website that will streamline PTO management for the department. I plan to incorporate ajax into the main page which will feature a calendar system for managers to view PTO requests week by week. To practice integrating ajax, I am starting with the "add Employee" page.
However, I am facing some challenges and can't seem to identify what is missing or why my code isn't functioning as expected.
The objective of the "add Employee" page is simply to add a new employee to the database without any display required. The main page consists of four text fields where I extract information from using JavaScript:
var firstName = document.getElementById("firstNameField");
var lastName = document.getElementById("lastNameField");
var manager = document.getElementById("managerField");
var networkID = document.getElementById("networkIDField");
So far, everything seems straightforward.
My ajax code setup includes the following steps (gathered from my research):
var url = "addEmpJSP.jsp?firstNameField=" + escape(firstName)+"&lastNameField="+escape(lastName)+"&managerField="+escape(manager)+"&networkIDField="+escape(networkID);
xmlhttp.open("POST",url,true);
xmlhttp.onreadystatechange=dummy;
xmlhttp.send(null);
This part is where I assume everything is correct, but being still relatively new to ajax, I'm unsure if I need to handle a response or if the called JSP file will automatically execute the necessary actions.
The JSP file is structured like this:
<%
ResultSet rsEmpl;
Connection connection1 = getDBConnection();
Statement statment1=connection1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
String fName = request.getParameter("firstNameField");
String lName = request.getParameter("lastNameField");
String manager = request.getParameter("managerField");
String networkID = request.getParameter("networkIDField");
Int empId = 0;
String EditEmplSQL = "select * from PTO_employee";
rsEmpl=statment1.executeQuery(EditEmplSQL);
rsEmpl.last();
empId = rsEmpl.getRow() - 1;
statement1.execute("INSERT INTO PTO_employee VALUES ("+empID+","+lName+","+fName+","+0+","+2+","+networkID);
%>
There's a button on the page that triggers the JavaScript function containing the ajax information. Currently, I am avoiding jQuery to focus on understanding the concepts before relying on shortcuts. My goal is to gain a thorough comprehension of web development as I pursue a degree in Software Engineering. If you require additional information, feel free to ask. Apologies for any confusion caused by my lack of expertise in this area.