如何优化WordPress插件中的JavaScript代码段?
- 内容介绍
- 文章标签
- 相关推荐
本文共计117个文字,预计阅读时间需要1分钟。
WordPress 同步插件的操作部分如下:javascriptfunction wp2wppush(postId) { var ajaxurl=; // 其他代码}
function wp2wppush(postId){ var ajaxurl = $('#ajaxurl').val(); var data = {postId:postId,action:'push'}; $.ajax({ url:ajaxurl, data:data, type:'POST', dataType:'json', beforeSend:function(){ $("#sync-content").html("Loding...."); }, success:function(msg){ if(msg.status==200){ // if(msg==200){ // alert(msg.status); $("#sync-content").html("当前文章同步成功!").css({"margin-bottom":"10px","border":"1px dashed gray"}); }else{ var html = "同步失败!"; html+=" "+msg.msg+" "; $("#sync-content").html(html).css("margin-bottom","10px"); } }, error:function(msg) { html="Sorry,unknown error."; $("#sync-content").html(html); } }) }
本文共计117个文字,预计阅读时间需要1分钟。
WordPress 同步插件的操作部分如下:javascriptfunction wp2wppush(postId) { var ajaxurl=; // 其他代码}
function wp2wppush(postId){ var ajaxurl = $('#ajaxurl').val(); var data = {postId:postId,action:'push'}; $.ajax({ url:ajaxurl, data:data, type:'POST', dataType:'json', beforeSend:function(){ $("#sync-content").html("Loding...."); }, success:function(msg){ if(msg.status==200){ // if(msg==200){ // alert(msg.status); $("#sync-content").html("当前文章同步成功!").css({"margin-bottom":"10px","border":"1px dashed gray"}); }else{ var html = "同步失败!"; html+=" "+msg.msg+" "; $("#sync-content").html(html).css("margin-bottom","10px"); } }, error:function(msg) { html="Sorry,unknown error."; $("#sync-content").html(html); } }) }

