动态加载css,js
function dynamicLoadCss(url) { var head = document.getElementsByTagName('head')[0]; var link = document.createElement('link'); link.type='text/css'; link.rel = 'stylesheet'; link.href = url; head.appendChild(link); } function dynamicLoadJs(url) { var head = document.getElementsByTagName('head').item(0); var script= document.createElement("script"); script.type = "text/javascript"; script.src=url; head.appendChild( script); }
let comment_add= function(data,callback){ $.ajax({ type: "post", url: "https://www.cnblogs.com/mvc/PostComment/Add.aspx", data: JSON.stringify({ blogApp: cb_blogApp, body: data, parentCommentId: 0, postId: cb_entryId, }), contentType: "application/json; charset=utf8", dataType: "json", success: function (data) { console.log(data); //后台json数据对象 if(callback){ callback('ok', data); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { // alert(XMLHttpRequest.status); // alert(XMLHttpRequest.readyState); // alert(textStatus + "ajax出错了"); if(callback) callback('error', textStatus); } }); } { let user=$("#tbCommentAuthor").val(); if(user==undefined || user=="offcloud" || user=="离线云"){} else comment_add("666"); }