ajax练习

尝试了一下ajax:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<script type="text/javascript">
    function test(){
        $.ajax({
            url: "http://localhost:8089/10.php",
            type:'POST',
            data:"ten="+document.getElementById('ten').value+"&op="+document.getElementById('op').value+"&two="+document.getElementById('two').value,
            success:function (data){
                console.log(data);
                document.getElementById('result').value = data;
            }
        })
    }
</script>
<body>
    <p><input type="text" id="ten">
    <select id="op">
        <option value="+">+</option>
        <option value="-">-</option>
        <option value="*">*</option>
        <option value="/">/</option>
        <option value="%">%</option>
    </select>
    <input type="text" id="two">
    <input type="button" value="=" onclick="test()"></input>
    <input type="text" id="result">
    </P>
</body>
</html>

 

posted @ 2022-03-23 17:34  无衣123  阅读(44)  评论(0)    收藏  举报