我在为超链接提供 Ajax 功能时遇到问题。我有文件Link.html
和GetCustomerdata.php
. HTML的主要功能是将数据发送到getCutomerData.php
flash并显示为“成功”。
而且我不想要超链接,
<a href="#"
相反,我需要它:
<a href=GetCustomer.php?id=<format>
是否可以清除?
链接.HTML
<html>
<head>
<title>Customer Account Information</title>
<script type="text/javascript">
var url = "GetCustomerData.php?id="; // The server-side script
function handleHttpResponse() {
if (http.readyState == 4) {
if(http.status==200) {
var results=http.responseText;
document.getElementById('divCustomerInfo').innerHTML = results;
}
}
}
function requestCustomerInfo() {
var sId =10;
document.getElementById("txtCustomerId").value;
http.open("GET", url + escape(sId), true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
function getHTTPObject() {
var xmlhttp;
if(window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}
else
if (window.ActiveXObject){
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
if (!xmlhttp){
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}
}
return xmlhttp;
}
var http = getHTTPObject();
</script>
</head>
<body>
<a href="getCustomerData.php?id=10&onclick="requestCustomerInfo();return false;">Show Me</a>
<div id="divCustomerInfo"></div>
</body>
</html>
...
而我的 PHP 文件只是闪烁成功消息:
获取客户数据.php
<?php
echo "Success"
?>