Ajax加载数据后百度分享实例
<script type="text/javascript"> //百度分享 function baidu_share() { var title_val = $("#video_title_id").val(); var content_val = $("#video_content_id").val(); var url_val = $("#video_url_id").val(); var img_val = $("#video_img_id").val(); window._bd_share_config = {"common": {"bdSnsKey": {}, "bdText": "", "bdMini": "2", "bdMiniList": false, "bdPic": "", "bdStyle": "0", "bdSize": "24"}, "share": { "tag": "share_123", //"bdSize" : 16, "bdText": title_val, "bdDesc": content_val, "bdUrl": url_val, "bdPic": img_val, }}; with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)]; } </script>
//开启视频 $('body').on('click', '.zhezhao', function () { var id = parseInt($(this).attr('v')); var url = '/pingce/getVideoInfo'; $.ajax({ type: "post", url: url, data: {id: id}, dataType: 'json', success: function (msg) { var data = msg.info; var str = ''; if (msg.status == 100) { //赋值到隐藏表单 $("#video_title_id").val(data.title); $("#video_content_id").val(data.content); $("#video_url_id").val(data.url); $("#video_img_id").val(data.img); $("#video_id_id").val(data.id); //加载分享代码 baidu_share(); } }, }); });