ajax发出,再次发出Ajax请求

// the XMLHttpRequest object I created in the constructor is called this.httpReqObj

// this.queryAddr is the servlet that handels the responses

if(this.httpReqObj == null || this.queryAddr == null)

{

return(false);

}

// check if XMLHttpRequest object is ready to send a new request.

if(this.getReadyState() != 0 && this.getReadyState() != 4)

{

return(false);

}

// the message queue contains strings, that should be sent to the server

if(this.msgQueue.hasNext())

{

var bundleMsg = "";

var bundleCtr = 0;

while(this.msgQueue.hasNext() && bundleCtr < DataRequester.BUNDLE_FACTOR)

{

bundleCtr ++;

bundleMsg += this.msgQueue.consume() + "&";

}

// remove last character of string

bundleMsg = bundleMsg.substring(0, bundleMsg.length - 1);

// "POST": choose the transport mechanism to the server

// "this.queryAddr": URL to which the query should be sent

// "true": communication should be asynchron

// if argument not available, assume method is true

if(typeof method == 'undefined')

{

method = true;

}

this.httpReqObj.open("POST", this.queryAddr, method);

// this function is called every time the status

// of the http request has changed. There exist five states.

// 0: not initialized

// 1: currently loading

// 2: finished loading

// 3: waiting for return

// 4: finished

if(method)

{

this.httpReqObj.onreadystatechange = createObjectCallback(obj, func);

}

// create header for POST query

this.httpReqObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

this.httpReqObj.setRequestHeader("Content-length", bundleMsg.length);

// send data to server

this.httpReqObj.send(bundleMsg);

// synchronous request

if(method == false)

{

return(this.getResponseXML());

}

}else

{

return;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值