function createHTTPObj_newvehicle() {
var http = null;
if (window.XMLHttpRequest)
http = new XMLHttpRequest();
else if (window.ActiveXObject)
http = new ActiveXObject("Microsoft.XMLHTTP");
return http;
}
function newvehicle() {
var http = createHTTPObj_newvehicle();
debugger;
http.open('POST', 'NavigateServlet?action=NewVehicle', true);
http.send(null);
}
function createHTTPObj_newbudget() {
var http = null;
if (window.XMLHttpRequest)
http = new XMLHttpRequest();
else if (window.ActiveXObject)
http = new ActiveXObject("Microsoft.XMLHTTP");
return http;
}
function newbudget() {
var http = createHTTPObj_newbudget();
debugger;
http.open('POST', 'NavigateServlet?action=NewBudget', true);
http.send(null);
}
javascript页面
<servlet>
<servlet-name>NavigateServlet</servlet-name>
<servlet-class>com.avigma.controller.NavigateServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>NavigateServlet</servlet-name>
<url-pattern>/NavigateServlet</url-pattern>
</servlet-mapping>
web.xml
答案 0 :(得分:0)
对于AJAX POST请求,您必须在open()
之后和send()
之前执行以下操作:
httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');