最近我一直在遇到发布功能无法正常工作的问题。我尝试了互联网上找到的所有方法,但没有任何帮助。 这是我的文件:
<html>
<head>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<script>
$(document).ready(function(){
$("#sendButton").click(function(){
event.preventDefault();
var text = document.getElementById("xd").value;
$.post("reg_send.php",
{
name: text
},
function(data){
$("#xd").html(data);
});
$("#xd").html("Trying");
});
});
</script>
</head>
<body>
<form style="width: 70%; margin: 0 auto;">
<p id="xd">TextHere</p>
<button type="button" class="mx-auto btn btn-danger" id="sendButton" data-toggle="collapse" data-target="#collapse1">Enviar</button>
</form>
</body>
</html>
还有reg_send.php文件:
<?php
echo "working";
?>
但它就是无法运行,而我也无法弄清楚原因。我尝试使用这个,但仍然没有用:
<script>
function send(){
$.post('reg_send',{},
function(data){
$("#Titulo").html("Xd");
});
}
</script>
在单击按钮的onClick上调用send()。我想将其用于XAMPP服务器,但尝试进行设置后仍无法使用。