PDA

View Full Version : Help with ajax basic routine



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.

xnpeng
02-26-2006, 11:43 PM
seems some wrong in parameters, when put url and parameter together in getAjaxRequest("GET",url+"?"+parameters,"","txt"), I can get correct result.

ddadmin
02-27-2006, 02:08 PM
Just to confirm then, are you still having problems with this script? The long delay btw can only be due to something on your backend taking its time to return the data.

xnpeng
02-28-2006, 07:24 AM
Not settle for postAjaxRequest. I use Tomcat5.5 jsp/servlet environment. My worry is that if I submit a set of data more than 1k, the "GET" method cannot handle it. Is that right?

thank you.