关闭窗口的操作 xmlhttp 的post取不到值, get取得到值
POST方式: 取不到值
<script language= "javascript ">
window.onbeforeunload = function()
{
var n = window.event.screenX - window.screenLeft;
var b = n > document.documentElement.scrollWidth-20;
if(b && window.event.clientY < 0 || window.event.altKey)
{
var xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP ");
ListString = "action=dl&qty=2&dID_1=39&dt_1=2000&dht_1=0&dID_2=44&dt_2=1000&dht_2=0 "
var Url = "tttt.asp "
xmlhttp.open( "post ", Url, false);
xmlhttp.setRequestHeader( "Content-Length ",ListString.length);
xmlhttp.setRequestHeader( "Content-Type ", "application/x-www-form-urlencode ")
xmlhttp.send(ListString);
alert(xmlhttp.responseText);
}
}
</script>
------------------------
GET方式: 可以取到值
<script language= "javascript ">
window.onbeforeunload = function()
{
var n = window.event.screenX - window.screenLeft;
var b = n > document.documentElement.scrollWidth-20;
if(b && window.event.clientY < 0 || window.event.altKey)
{
var xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP ");
xmlhttp.open( "get ", "tttt.asp?action=dl&qty=2&dID_1=39&dt_1=2000&dht_1=0&dID_2=44&dt_2=1000&dht_2=0 ", false);
xmlhttp.send();
alert(xmlhttp.responseText);
}
}
</script>
------------------------
tttt.asp
action=Replace(trim(Request( "action ")), " ' ", " ")
qty=Replace(trim(CLng(Request( "qty "))), " ' ", " ")
dID_1=Replace(trim(CLng(Request( "dID_1 "))), " ' ", " ")
dt_1=Replace(trim(CLng(Request( "dt_1 "))), " ' ", " ")
dht_1=Replace(trim(CLng(Request( "dht_1 "))), " ' ", " ")
dID_2=Replace(trim(CLng(Request( "dID_2 "))), " ' ", " ")
dt_2=Replace(trim(CLng(Request( "dt_2 "))), " ' ", " ")
dht_2=Replace(trim(CLng(Request( "dht_2 "))), " ' ", " ")
Response.Write action& " "&qty& " "&dID_1& " "&dt_1& " "&dht_1& " "&dID_2& " "&dt_2& " "&dht_2
Response.End
------------------------
把 Request改为 Request.Form ,POST也一样取不到值
请问,是哪里出了问题?谢谢!!
------解决方案--------------------open后这样吧.
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
alert(xmlhttp.responseText)
}