我有一些按钮被按下时重定向的AJAX代码。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";
?>
想法?
在'form'标签中添加'onsubmit =“返回false;”''。 – Leri
所以它重定向,这是错误的,或者应该是重定向...?它应该怎么做?如果你不想让它在任何地方重定向,就像在其他人提到的那样,在按钮上或onsubmit上添加“返回false”。 – eis
这是重定向,我不希望它。 PLB我在表单标签中尝试了这些代码,但没有运气。 – KriiV