会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132486个问题

<!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>测试自定义Ajax</title>

    <script src="js/beixiAjaxBaseUtil.js"></script>

    <style>

        .getModal{border:1px solid black;padding: 10px;width: 400ox;margin-bottom: 10px;}

        .postModal{border:1px solid black;padding: 10px;width: 400ox;}


    </style>

</head>

<body>

    <div class="getModal">

         <span>用户名:</span><input type="text" clasa="getUserName"><br/>

         <span>密码:</span><input type="text" clasa="getPassword"><br/>

         <button class="get_noparam_btn">get无参请求</button>$nbsp;$nbsp;$nbsp;

         <button class="get_param_btn">get有参请求</button>

    </div>

    <div class="postModal">

        <span>用户名:</span><input type="text" clasa="postUserName"><br/>

        <span>密码:</span><input type="text" clasa="postPassword"><br/>

        <button class="post_btn">post参请求</button>

   </div>

   <script>

     //页面元素

     var getUserNameInput= document.querySelector('.getUserName');

       var getPasswordInput= document.querySelector('.getPassword');

       var postUserNameInput= document.querySelector('.postUserName');

       var postPasswordInput= document.querySelector('.postPassword');

       var get_noparam_btn= document.querySelector('.get_noparam_btn');

       var get_param_btn= document.querySelector('.get_param_btn');

       var post_btn= document.querySelector('.post_btn');

        //测试get无参请求

        get_noparam_btn.onclick=function(){

            window.beixiAjax({

                type:'get',

                url:'09测试自定义Ajax.php',

//                data:{},

                success:function(res){

                    console.log(res.imgSrc);

                    var img=document.createElement('img');

                    img.src=res.imgSrc;

                    document.body.appendChild(img);

                }

            });

        }

        //测试get有参请求

        get_param_btn.onclick=function(){

            window.beixiAjax({

                type:'get',

                url:'09测试自定义Ajax.php',

                data:{

                    getName:getUserNameInput.value,

                    getPass:getPasswordInput.value

                },

                success:function(res){

                    console.log(res);

                }

            });

        }

        //测试post请求

        post_btn.onclick=function(){

            window.beixiAjax({

                type:'post',

                url:'09测试自定义Ajax.php',

                data:{

                    postName:postUserNameInput.value,

                    postPass:postPasswordInput.value

                },

                success:function(res){

                    console.log(res);

                }

            });

        }

   

   </script>

</body>

</html>


<?php

    $success=array('msg'=>'ok');

    if($_POST){

          $success['info']=$_POST;

    }else{

         $success['info']=$_GET;

    }

    echo  json_encode($success);

?>

image.png

求解


WEB前端全系列/第六阶段:Http服务与Ajax模块(旧)/Http服务与Ajax编程 14566楼
Java架构课程/第八阶段:搜索服务/Solr 14568楼
JAVA 全系列/第三阶段:数据库编程/JDBC技术(旧) 14569楼
WEB前端全系列/第三阶段:jQuery编程模块/jQuery基础知识(旧) 14570楼
Python 全系列/第一阶段:Python入门/控制语句 14571楼
Python 全系列/第一阶段:Python入门/控制语句 14573楼
WEB前端全系列/第二阶段:JavaScript编程模块/运算符_数据类型和流程循环语句 14574楼
JAVA 全系列/第三阶段:数据库编程/SQL 语言 14578楼

image.png



https://www.jq22.com/jq2-jq

老师,我在网上下载动画要怎样用??

Python 全系列/第七阶段:网页编程基础/jquery 14579楼
Python 全系列/第一阶段:Python入门/面向对象 14580楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637