热门关键字:
jquery > jquery教程 > jquery教程 > 使用jQuery使用AJAX执行GET请求

使用jQuery使用AJAX执行GET请求

357
作者:管理员
发布时间:2021/1/30 14:08:45
评论数:0
转载请自觉注明原文:http://www.jq-school.com/Show.aspx?id=3664
下面的示例使用jQuery$.get()方法使用HTTP GET方法向“ date-time.php”文件发出Ajax请求。它只是检索从服务器返回的日期和时间,并在浏览器中显示它而无需刷新页面。


例试试这个代码»
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery get() Demo</title>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $.get("date-time.php", function(data){
            // Display the returned data in browser
            $("#result").html(data);
        });
    });
});
</script>
</head>
<body>
    <div id="result">
        <h2>Content of the result DIV box will be replaced by the server date and time</h2>
    </div>
    <button type="button">Load Date and Time</button>
</body>
</html>




如果您觉得本文的内容对您的学习有所帮助:支付鼓励



关键字:jQuery
友荐云推荐