Ich habe eine Datentabelle und ich füge eine neue Zeile und übermittle es an eine JSP für die Datenbankeinfügung. Ich erhalte den folgenden Fehler in JSP. Was ist das Problem mit diesem Code?Java Script Datenbank Einfügung
You have an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near '[object HTMLInputElement]' at line 4] with root cause
JS - Ajax Code JSP auf Klick auf Schaltfläche Speichern
function addRow(table,row)
{
var input = $('input', row);
var params = "id="+input[0].value+"&name="+input[1].value+"&title="+input[2].value+"&code="+input[3].value+"&email="+input[4].value+"&band="+input[5].value+"&location="+input[6].value+"&manager="+input[7].value+"&school="+input[8].value+"&major="+input[9].value+"&years="+input[10].value+"&edu="+input[11].value+"&skills="+input[12].value;
var settings = {
"async": true,
"crossDomain": true,
"timeout":0,
"url": "insertdb.jsp?"+params,
"method": "POST",
"headers": {
"content-type": "application/json",
"cache-control": "no-cache"
},
"processData": false
}
$.ajax(settings).done(function (response) {
var json = JSON.parse(response);
if(json.responseHeader.status == "0")
{
alertify.success("Sucessfully modified the schema field");
location.reload();
//alertify.set({ delay : 5000 });
}
else
{
alertify.error("Error! Please try again");
}
console.log(response);
});
}
MY JSP einreichen
<sql:update dataSource="${myDS}" var="result">
insert into emp_profile1 (EMPID, NAME, JOB_TITLE, JOB_CODE, EMAIL, BAND, LOCATION, MANAGER, SCHOOL, MAJOR, YEARS_EXP, EDUCATION, SKILLS) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?);
<sql:param value="${param.id}" />
<c:out value="${param.name}"></c:out>
<sql:param value="${param.name}" />
<sql:param value="${param.title}" />
<sql:param value="${param.code}" />
<sql:param value="${param.email}" />
<sql:param value="${param.band}" />
<sql:param value="${param.location}" />
<sql:param value="${param.manager}" />
<sql:param value="${param.school}" />
<sql:param value="${param.major}" />
<sql:param value="${param.years}" />
<sql:param value="${param.edu}" />
<sql:param value="${param.skills}" />
</sql:update>
response.setContentType("text/html");
<c:if test="${result>=1}">
response.getWriter().print("{'success': true}");
</c:if>
zu verwenden, war meine Antwort hilfreich ? Dann können Sie es akzeptieren und upvote, indem Sie auf das Häkchen und den Pfeil nach oben auf der linken Seite klicken. Wenn Sie weiterhin Probleme haben, geben Sie bitte weitere Informationen an. –