누군가가 다음을보고 내 서버가 내 아약스로부터 어떤 전화를받지 못하고 있는지 말해 줄 수 있습니까? 경고 팝업하지만 아무것도 서버에 ??Ajax가 서버에 게시되지 않는 이유는 무엇입니까?
JSP 코드 :
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>This is a project to show how to use RESTful</title>
</head>
<body>
<script src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script src="<%=request.getContextPath()%>/js/add.js"></script>
<H1>Add Employee</H1>
<p>
<form name="htmlform">
<table border=1>
<thead><tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
</tr></thead>
<tr>
<td><input type="text" name="ID" maxlength="5" size="3"></td>
<td><input type="text" name="Name" maxlength="10" size="10"></td>
<td><input type="text" name="Email" maxlength="10" size="10"></td>
</tr>
</table>
<input type="button" value="Save Employee" onclick="doAjaxPost();" />
<p>
<p>
</form>
[<a href="http://localhost:8080/RESTful/service/employees">List all Employees</a> | <a href="add.jsp">Employee Form Test</a>]
</body>
</html>
ADD.JS 코드 :
function doAjaxPost() {
alert("doAjaxPost called");
$.ajax({
contentType : "application/json",
dataType : 'json',
type : "PUT",
url : contexPath + "/service/employee",
data : $(this).serializeObject(),
success : function(data) {
alert("Thanks for submitting. \n\n" + response.result);
// response
},
error : function(request, status, error) {
alert('Error: ' + e);
}
});
}
자바 스크립트 오류가없고 네트워크 오류가 없는지 확인하려면 브라우저의 콘솔을 살펴보십시오. –