我尝试了下面的代码,通过单击按钮向jsp页面发送请求。我检查了Httpfox,但没有要求。我只是在html代码的主体中使用了整个代码。我在做一些愚蠢的错误吗?请建议..XMLHTTP请求请求不起作用
<button type="button" onClick="handleButtonClick();">Click Me!</button>
<script type="text/javascript">
function handleButtonClick()
{
// Declare the variables we'll be using
var xmlHttp, handleRequestStateChange;
// Define the function to be called when our AJAX request's state changes:
handleRequestStateChange = function()
{
// Check to see if this state change was "request complete", and
// there was no server error (404 Not Found, 500 Server Error, etc)
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var substring=xmlHttp.responseText;
// Do something with the text here
alert(substring);
}
}
xmlhttp = new XMLHttpRequest();
xmlHttp.open("GET", "http://csce:8080/test/index.jsp?id=c6c684d9cc99476a7e7e853d77540ceb", true);
xmlHttp.onreadystatechange = handleRequestStateChange;
xmlHttp.send(null);
}
</script>
好搭档!完全错过了,当我检查它。这很可能是。 – 2010-10-18 04:28:03
谢谢我没有意识到我正在使用不同的情况... – Judy 2010-10-18 04:49:32