我的程序的ajax部分一直在运行,直到我将jquery版本更新为3.3.1时,我已经使用了jquery 1.7版本。我已经附加了代码的ajax部分。在php文件中我只使用inset post方法获取数据并运行mysql查询。如果找到的行号为0,则回显否是。
这里是ajax代码:
$.ajax({
type: "POST",
url: "ajax.php",
data: "username="+ username,
success: function(msg){
$("#status").ajaxComplete(function(event, request){
Then codes need to be run.
Then close all braces.
答案 0 :(得分:0)
<?php
if(isset($_REQUEST['username'])){
echo $_REQUEST['username'];die;
}
?>
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.ajax({
type: "POST",
url: "<site_url>/demo.php",
data: "username=hello",
success: function(msg){
alert(msg);
}});
});
$(document).ajaxComplete(function(event, request){
alert("ajaxComplete");
});
});
</script>
</head>
<body>
<div id="div1"><h2>Let jQuery AJAX Change This Text</h2></div>
<button>Call Ajax Demo</button>
<body>
</html>