如何使用ajax
调用此sample.php页面$server1 = "localhost"; //Your MySQL Server
$user1 = "root"; //Your MySQL username
$pass1 = ""; //Password
$dbname1 = "test";
$conn1 = mysql_connect($server1, $user1, $pass1) or die(mysql_error());
$db1 = mysql_select_db($dbname1, $conn1) or die(mysql_error());
echo $result = mysql_query($conn1, " CALL users($id)"));
我不知道如何编写ajax函数调用sample.php
答案 0 :(得分:1)
在您的HTML页面中添加此代码。如果您需要传递一些参数,请添加{ id: id }
$.ajax({
type: "POST",
url: "sample.php",
data: { id: id }
})
.done(function( result) {
alert( "Response: " + result);
});
答案 1 :(得分:0)
$.ajax({
url: "sample.php",//url of the page where the request is to be send
type: "POST",//request type get or post
data: { },//if any data is to send with the request
success:function(res){
//Do something if you have to do anything on success
}
});
您可以看到 DOCUMENTATION 了解更多