我有一些 AJAX 代码在按下按钮时重定向。
它正在重定向到 members.php
这是 AJAX 代码:
<script language="javascript" type="text/javascript">
function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Please update your browser.");
return false;
}
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
// We still need to write some code here
if(ajaxRequest.readyState == 4){
// Get the data from the server's response
response = ajaxRequest.responseText;
}
}
ajaxRequest.open("GET", "accept.php?id=<?php echo $articleid; ?>&state=accept$p=a9dafdd0fe68c6f64841e265e1c8832a", true);
ajaxRequest.send(null);
}
</script>
这是按钮:
<input type="submit" onChange="ajaxFunction();" />
这是accept.php的内容:
<?php
echo "ACCEPTED";
?>
想法?