jq 实现第二个html页面接受第一个html页面的参数并模拟渲染数据

本文展示了如何使用jQuery在两个HTML页面间传递参数。第一个页面的JS代码涉及数据发送,第二个页面接收数据并模拟渲染智慧食堂的相关信息,包括时间、来源、作者、文章概要和关键亮点。通过解析JSON文件,展示了智慧食堂的智能化特点,如快速结算、食品安全监管和信息化建设等。
摘要由CSDN通过智能技术生成

第一个html页面的js代码:

$.ajax({
   
        url:"/xinyuncan/json_home/data.json",    //读取的是项目中测试用的json文件
        type:"GET",
        dataType:"json",
        success:function(data){
   
            console.log("连接成功"+data);
            showData(data);
        },
        error:function(e){
   
            console.log("连接失败"+e);
        }
    })
    function showData(data){
   

        console.log(data.mTitle);
        console.log($(".dt h3"));
        $(".dt .new_box4").each(function(index){
   
            $(this).click(function(){
   
                location.href = "page2hydt.html?" + "index=" + encodeURI(index);
            })
            $(this).find("h3").html(data.hydt[index].mTitle);
            $(this).find("p").html(data.hydt[index].desPart.one);
            $(this).find("span").html("新闻快讯/"+data.hydt[index].time);
        })
        
        $(".xw .new_box4").each(function(index){
   
            $(this).click(function(){
   
                location.href = "page2gsxw.html?" + "index=" + encodeURI(index);     //此处为url传递参数的方法,将当前div下标传过去,让第二个html页面读取指定下标的json数据
            })
            $(this).find("h3").html(data.gsxw[index].mTitle);
            $(this).find("p").html(data.gsxw[index].desPart.one);
            $(this).find("span").
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值