jquery ajax的例子

来源:互联网 发布:cmmi软件过程管理体系 编辑:程序博客网 时间:2024/05/22 03:30

首先引入jquery.js文件


<div class="row" id="row">    <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 ana_btn">        <img  src="" alt="Responsive image" class="img-responsive ana_btn_con img-rounded">        <a target="_blank" href=""           style="color: #1b6d85; margin-top: 20px;font-size: 18px;margin-bottom: 20px"></a>        <p style="color: #777"></p>    </div>
</div>


$(document).ready(function(){    var root = location.href.slice(0, location.href.lastIndexOf('/'));    var path = root + '/appgallery/config/appsConfig.json';    //$("#imgId").attr('src',path);    var childrens = $('body').find("#row")[0].children;   //查找节点    $.ajax({        type:"GET",        url: path,        data:{},       dataType: 'json',        success:function(results){            var centents = results.typicalAPPContents;            for(var i=0;i<childrens.length-1;i++){               var childs =  childrens[i].children;               //childs[0].attr("src",centents[i].image);   修改属性                childs[0].src = centents[i].image;                childs[1].href = centents[i].url;                childs[1].text = centents[i].title;                childs[2].innerText = centents[i].content;               // childs[1].         }        },        error:function(){            alert("没有配置要打开的连接");        }    });})

0 0
原创粉丝点击