表单和AJAX提交请求

表单和AJAX提交请求

前后端交互过程

一、简介

前后端的交互过程就是HTTP协议的处理过程:请求与响应的处理过程。单纯只有前端,无法使用后台服务器的能力,或者无法访问数据库,如果单纯只有后端,也无法形成业务流程,无法为客户产生价值。

image-20240214150006887

三种方式:

(1)资源获取型:GET请求+URL地址

(2)数据提交型:POST请求+URL地址+请求正文

(3)AJAX提交:利用异步提交方式,在不刷新当前页面情况下,提交数据给后台

第三种就类似于,如下两种情况

image-20240214152047889

image-20240214152101341

二、POST请求

以下请求方式使用form表单的形式发送post请求

(1)必须使用form标签将所有表单元素包裹起来

(2)必须要在form标签中指定action属性

(3)必须要在form标签中指定method属性

<form action="../PHP/login.php" method="post">

(4)必须要确保在form标签内,有至少一个按钮,且按钮 type="submit"

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ymqyyds</title>
    <style>

        div {
     
            width: 310px;
            height: 75px;
            margin: auto;
        }

        .title {
     
            color: rgb(6, 255, 52);
            font-size: 30px;
            text-align: center;
            margin-top: 200px;
            padding-bottom: 10px;  /*和底部下一个容器相隔一点距离*/
            font-weight: bold;  /*加粗*/
            font-style: italic;  /*斜体*/
            
        } 

        input {
     
            width: 300px;
            height: 50px;
            background-color: antiquewhite;
            border-radius: 5px;  /*让边框看起来圆润一点*/
            text-align: center;
            margin: auto;
        }

        button {
     
            width: 310px;
            height: 50px;
            background-color: fuchsia;
            color: chartreuse;
            font-size: 20px;
            font-weight: bold;  /*加粗*/
            font-style: italic;  /*斜体*/
            border-radius
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值