会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132948个问题
JAVA 全系列/第二阶段:JAVA 基础深化和提高/异常机制 29161楼

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="jquery-3.5.1.js"></script>
</head>
<body>
    <span>用户名:</span><input type="text" class="userName">
    <br>
    <span>密码:</span><input type="text" class="userPsw">
    <br>
    <button>登录</button>
    <script>
       /* $('button').click(function () {
            $.ajax({
                type:'post',
                url:'10jqAjax请求.php',
                dataType:'json',
                data:{
                    myName:$('.userName').val(),
                    myPsw:$('.userPsw').val()
                },
                success:function (res) {
                    console.log(res.infocode);
            };
        })*/
            $('button').click(function () {
                $.ajax({
                    type:'post',
                    url:'10jqAjax请求.php',
                    dataType:'json',
                    data:{
                        myName:$('.userName').val(),
                        myPsw:$('.userPsw').val()
                    },
                    success:function (res) {
                        console.log(res);
                        console.log(res.infocode);
                        if (res.infocode == 0){
                            alert('登录失败');
                        }else{
                            alert('登录成功');
                        }
                    }
                })
            })
    </script>
</body>
</html>
============================================
<?php
    $username = $_POST['myName'];
    $userpsw = $_POST['myPsw'];
    $success = array('msg'=>'ok');
    if($username=='zhangsan' && $userpsw=='123456'){
        //登陆成功1:登录成功  0:登陆失败
        $success['infocode']=1;
    }else{
        //登陆失败
        $success['infocode']=0;
    }
    echo json_encode($success);
?>

老师,请问一下我的代码在前台为什么访问不到后台的infocode,导致点击登录页面的时候不管输入的用户名和密码正不正确都是显示登陆成功,麻烦帮我看一下是哪里的问题?image.png



WEB前端全系列/第五阶段:前后端交互/PHP、数据库编程与设计 29162楼
JAVA 全系列/第三阶段:数据库编程/SQL 语言 29164楼
Python 全系列/第一阶段:Python入门/编程基本概念 29165楼

老师,我这个图表数据要显示在条状图上面,该怎么弄?

import requests
from lxml import etree
from fake_useragent import UserAgent
from matplotlib import pyplot as plt

def get_price_data():
    url = 'https://fdc.fang.com/data/land/land_cd.htm'
    headers = {'User-Agent':UserAgent().chrome}
    resp = requests.get(url,headers=headers)
    e = etree.HTML(resp.text)
    dates = [ele.strip() for ele in e.xpath('//table[@class="ltab01"]//tr/td[1]/text()')[-1:1:-1]]
    prices = [float(i) for i in e.xpath('//table[@class="ltab01"]//tr/td[4]/text()')[-1:1:-1]]
    return dates,prices
    
def test07(): # 绘制纵向条状图
    # 构造数据
    dates,prices = get_price_data()
    x = range(6)
    # 设置中文显示
    plt.rcParams['font.family'] = ['SimHei']
    # 设置x轴刻度
    plt.xticks(x,dates)
    # 在图表上显示值
    for m,n in zip(x,prices):
        plt.text(m,m,n) # 第一个参数是值的间距,第二个参数是自变量,第三个参数是因变量
    # 填充数据
    plt.bar(x,prices,color='red',width=0.5)# color参数设置颜色,width参数设置宽度
    # 设置图表标题
    plt.title('2020年成都土地成交数据')
    # 设置x轴说明
    plt.xlabel('月份')
    # 设置y轴说明
    plt.ylabel('成交均价(元/㎡)')
    # 显示图表
    plt.show()

if __name__ == '__main__':
    test07()

运行结果:

image.png






Python 全系列/第十七阶段:数据分析-数据可视化/matplotlib 29173楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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