xnpeng
02-26-2006, 04:28 PM
I am having problems using the basic script:
http://www.dynamicdrive.com/dynamicindex17/ajaxroutine.htm
my code is like this:
function DoSave() {
var parms = "ActionType=Save";
var f = document.frmEdit;
ajaxpack.getAjaxRequest("save.jsp", parms, processGetPost, "txt");
//ajaxpack.postAjaxRequest("save.jsp", parms, processGetPost, "txt"); }
function processGetPost() {
var myajax = ajaxpack.ajaxobj;
var myfiletype = ajaxpack.filetype;
if (myajax.readyState == 4) {
if (myajax.status == 200 || window.location.href.indexOf("http") == -1) {
if (myfiletype == "txt")
alert(myajax.responseText);
else
alert(myajax.responseXML);
}
}
}
save.jsp
<%
String actionType = request.getParameter("ActionType");
out.print(actionType);
%>
when I use getAjaxRequest,it return a "null" to me, while use postAjaxRequest, it delays 2-3 minutes to return me a "Save" string, --that's correct result.
The question is ,
1, why cannot I get a correct result from getAjaxRequest?
2, why do postAjaxRequest need so much time in return a simple value?
thanks.
http://www.dynamicdrive.com/dynamicindex17/ajaxroutine.htm
my code is like this:
function DoSave() {
var parms = "ActionType=Save";
var f = document.frmEdit;
ajaxpack.getAjaxRequest("save.jsp", parms, processGetPost, "txt");
//ajaxpack.postAjaxRequest("save.jsp", parms, processGetPost, "txt"); }
function processGetPost() {
var myajax = ajaxpack.ajaxobj;
var myfiletype = ajaxpack.filetype;
if (myajax.readyState == 4) {
if (myajax.status == 200 || window.location.href.indexOf("http") == -1) {
if (myfiletype == "txt")
alert(myajax.responseText);
else
alert(myajax.responseXML);
}
}
}
save.jsp
<%
String actionType = request.getParameter("ActionType");
out.print(actionType);
%>
when I use getAjaxRequest,it return a "null" to me, while use postAjaxRequest, it delays 2-3 minutes to return me a "Save" string, --that's correct result.
The question is ,
1, why cannot I get a correct result from getAjaxRequest?
2, why do postAjaxRequest need so much time in return a simple value?
thanks.