Javascript 在单击Jquery切换按钮时,应该执行一些PHP过程,而不重定向页面
我在Jquery上有一个切换按钮,它必须显示一些额外的信息。它工作得很好,我想在PHP上做一些处理,以便在后端不重定向显示一些额外信息的切换页面。我的头伤得太久了。请帮帮我。。。这是我的Jquery代码Javascript 在单击Jquery切换按钮时,应该执行一些PHP过程,而不重定向页面,javascript,php,jquery,mysql,Javascript,Php,Jquery,Mysql,我在Jquery上有一个切换按钮,它必须显示一些额外的信息。它工作得很好,我想在PHP上做一些处理,以便在后端不重定向显示一些额外信息的切换页面。我的头伤得太久了。请帮帮我。。。这是我的Jquery代码 <div class="hidetext"></div> <script type="text/javascript" language="javascript"> $(document).ready(function() { $(".
<div class="hidetext"></div>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$(".hidetext").click(function () {
$(".text").toggle("slow",function(){
});
});
});
$('#hidetext').change(function() {
this.form.submit();
});
</script>
<form action="http://localhost/test/test/index.php" method="post" id="doSite">
<input type="hidden" name="credits" value="<?php echo $email;?>">
<input type="hidden" name="credits" value="<?php echo 2;?>">
<button class="hidetext">Click More Info</button>
</form>
您可以使用ajax实现这一点
$.ajax({
dataType: "json",
data: {"x": $x},
url: 'php/x.php',
type: 'post',
beforeSend: function(){
//What is done before to send
},
success: function(respuesta){
//what is done after send
$("x").html(respuesta.html);
},
error: function(xhr,err){
alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status+"\n \n responseText: "+xhr.responseText);
}
});
阿贾克斯是你的朋友。请查看您正在使用的“hidetext”,它不存在。