\u4e24\u79cd\u65b9\u5f0f\u6267\u884c\u5916\u90e8\u63d2\u4ef6\u6302\u8f7d\u7684js\u811a\u672c<\/a><\/p>\n\n\n\n
\n\n\n\n\u4e0b\u9762\u6211\u5c31\u4ee5\u6700\u5178\u578b\u7684Willin Kan\u7248\u7684ajax\u8bc4\u8bba\u6765\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u56e0\u4e3a\u5f88\u591a\u5c0f\u4f19\u4f34\u5b8c\u6210\u9875\u9762ajax\u4e4b\u540e\uff0c\u8bc4\u8bbaajax\u603b\u662f\u5931\u6548\uff0c\u4e0b\u9762\u5148\u770b\u770b\u8fd9\u4e2a\u8bc4\u8bbaajax\u4ee3\u7801\uff1a<\/p>\n\n\n\n
var theme_dir = $('head #default-css').attr('href').split('style.css')[0]; \/\/ \u4e3b\u9898\u8def\u5f84 \uff0c\u4ee5style.css\u5206\u5272href\uff0c\u7b2c\u4e00\u6bb5\u5c31\u662f\u4e3b\u9898\u8def\u5f84\n\n\/**\n * WordPress jQuery-Ajax-Comments v1.3 by Willin Kan.\n * URI: http:\/\/kan.willin.org\/?p=1271\n *\/\n var commentform = '#comment_form', \/\/ \u00d7\u00d7\u00d7 form\u8868\u5355id\n comment = 'c_tarea', \/\/ \u00d7\u00d7\u00d7 textarea \u7684id \u4e0d\u5e26#\n commentlist = 'comment-list', \/\/ \u00d7\u00d7\u00d7 \u8bc4\u8bba\u5217\u8868ul\u6216ol\u7684class\uff0c\u4e0d\u5e26\u70b9\n respond = '#respond', \/\/ \u00d7\u00d7\u00d7 \u8bc4\u8bba\u63d2\u5165\u4f4d\u7f6e\uff0c\u63d2\u5165\u5728\u8fd9\u4e2aid\u4e4b\u524d\n homeUrl = document.location.href.match(\/http:\\\/\\\/([^\\\/]+)\\\/\/i)[0], \/\/ \u4e3b\u9875\u5730\u5740\uff0c\u7528\u4e8e\u4e0b\u9762\u7684\u63d0\u4ea4\u51fd\u6570\n txt1 = '<div id=\"loading\" class=\"text-info\"> \u6b63\u5728\u63d0\u4ea4, \u8bf7\u7a0d\u5019...<\/div>',\n txt2 = '<div id=\"error\">#<\/div>',\n txt3 = '\"><div class=\"text-success\"> OK !',\n edt1 = ' \u5237\u65b0\u9875\u9762\u4e4b\u524d\u60a8\u53ef\u4ee5<a rel=\"nofollow\" class=\"comment-reply-link\" href=\"#edit\" onclick=\\'return addComment.moveForm(\"',\n edt2 = ')\\'>\u518d\u6b21\u7f16\u8f91\u8bc4\u8bba<\/a><\/div>',\n cancel_edit = '\u53d6\u6d88\u7f16\u8f91',\n edit,\n num = 1,\n $comments = $('#response'), \/\/ \u8bc4\u8bba\u6570\n $cancel = $('#cancel-comment-reply-link'),\n cancel_text = $cancel.text(),\n $submit = $(commentform+ '#submit');\n $submit.attr('disabled', false),\n $body = (window.opera) ? (document.compatMode == \"CSS1Compat\" ? $('html') : $('body')) : $('html,body'),\n comm_array = [];\n comm_array.push('');\n $('#'+comment).after(txt1 + txt2); \/\/ \u00d7\u00d7\u00d7 textarea\u7684id\u6216class\n $('#loading').hide();\n $('#error').hide();\n \/\/ \u8bc4\u8bba\u63d0\u4ea4\n\/\/ $(commentform).submit( \/\/ \u975e\u52a8\u6001\u7ed1\u5b9a\n$(document).on(\"submit\", commentform, \/\/\u52a8\u6001\u7ed1\u5b9a\n function() {\n if (edit) $('#'+comment).after('<input type=\"text\" name=\"edit_id\" id=\"edit_id\" value=\"' + edit + '\" style=\"display:none;\" \/>');\n $submit.attr('disabled', true).fadeTo('slow', 0.5);\n $('#loading').slideDown();\n $.ajax({\n url: theme_dir + '\/comt-ajax.php',\n data: $(this).serialize() ,\n type: $(this).attr('method'),\n error: function(request) {\n $('#loading').slideUp();\n $(\"#error\").slideDown().html(request.responseText);\n setTimeout(function() {\n $submit.attr('disabled', false).fadeTo('slow', 1);\n $('#error').slideUp();\n },\n 3000);\n },\n success: function(data) {\n $('#loading').hide();\n comm_array.push($('#'+comment).val());\n $('textarea').each(function() {\n this.value = ''\n });\n var t = addComment,\n cancel = t.I('cancel-comment-reply-link'),\n temp = t.I('wp-temp-form-div'),\n respond = t.I(t.respondId),\n post = t.I('comment_post_ID').value,\n parent = t.I('comment_parent').value;\n \/\/ \u589e\u52a0\u8bc4\u8bba\u6570\n if (!edit && $comments.length) { \n n = parseInt($comments.text().match(\/\\d+\/)); \/\/ \u5339\u914d\u6570\u5b57\n $comments.text($comments.text().replace(n, n + 1));\n }\n \/\/ \u8bc4\u8bba\u663e\u793a\n new_htm = '\" id=\"new_comm_' + num + '\"><\/';\n new_htm = (parent == '0') ? ('\\n<ol style=\"clear:both;\" class=\"'+commentlist+'\" ' + new_htm + 'ol>') : ('\\n<ul class=\"children' + new_htm + 'ul>');\n ok_htm = '\\n<div class=\"ajax-notice\" id=\"success_' + num + txt3;\n div_ = (document.body.innerHTML.indexOf('div-comment-') == -1) ? '': ((document.body.innerHTML.indexOf('li-comment-') == -1) ? 'div-': '');\n ok_htm = ok_htm.concat(edt1, div_, 'comment-', parent, '\", \"', parent, '\", \"respond\", \"', post, '\", ', num, edt2);\n ok_htm += '<\/span><span><\/span>\\n';\n ok_htm += '<\/div>\\n';\n if($('#comments .comment-list').length>0){ \/\/ \u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u975e\u5d4c\u5957\u8bc4\u8bba\u65f6\uff0c\u65b0\u8bc4\u8bba\u663e\u793a\u63d2\u5165\u7684\u4f4d\u7f6e\uff08\u6309\u81ea\u5df1\u7684\u559c\u597d\u4fee\u6539\u663e\u793a\u4f4d\u7f6e\uff09\n $('#comments .comment-list').before(new_htm);\n } else{\n $('#respond').after(new_htm);\n }\n $('#new_comm_' + num).append(data);\n $('#new_comm_' + num + ' li').append(ok_htm);\n $body.animate({scrollTop: $('#new_comm_' + num).offset().top - 200},900);\n countdown();\n num++;\n edit = '';\n $('*').remove('#edit_id');\n cancel.style.display = 'none';\n cancel.onclick = null;\n t.I('comment_parent').value = '0';\n if (temp && respond) {\n temp.parentNode.insertBefore(respond, temp);\n temp.parentNode.removeChild(temp)\n }\n }\n });\n return false;\n });\n addComment = {\n moveForm: function(commId, parentId, respondId, postId, num) {\n var t = this,\n div,\n comm = t.I(commId),\n respond = t.I(respondId),\n cancel = t.I('cancel-comment-reply-link'),\n parent = t.I('comment_parent'),\n post = t.I('comment_post_ID');\n if (edit) exit_prev_edit();\n num ? (t.I(comment).value = comm_array[num], edit = t.I('new_comm_' + num).innerHTML.match(\/(comment-)(\\d+)\/)[2], $new_sucs = $('#success_' + num), $new_sucs.hide(), $new_comm = $('#new_comm_' + num), $new_comm.hide(), $cancel.text(cancel_edit)) : $cancel.text(cancel_text);\n t.respondId = respondId;\n postId = postId || false;\n if (!t.I('wp-temp-form-div')) {\n div = document.createElement('div');\n div.id = 'wp-temp-form-div';\n div.style.display = 'none';\n respond.parentNode.insertBefore(div, respond)\n } ! comm ? (temp = t.I('wp-temp-form-div'), t.I('comment_parent').value = '0', temp.parentNode.insertBefore(respond, temp), temp.parentNode.removeChild(temp)) : comm.parentNode.insertBefore(respond, comm.nextSibling);\n $body.animate({scrollTop: $('#respond').offset().top - 180},400);\n if (post && postId) post.value = postId;\n parent.value = parentId;\n cancel.style.display = '';\n cancel.onclick = function() {\n if (edit) exit_prev_edit();\n var t = addComment,\n temp = t.I('wp-temp-form-div'),\n respond = t.I(t.respondId);\n t.I('comment_parent').value = '0';\n if (temp && respond) {\n temp.parentNode.insertBefore(respond, temp);\n temp.parentNode.removeChild(temp);\n }\n this.style.display = 'none';\n this.onclick = null;\n return false;\n };\n try {\n t.I(comment).focus();\n }\n catch(e) {}\n return false;\n },\n I: function(e) {\n return document.getElementById(e);\n }\n };\n function exit_prev_edit() {\n $new_comm.show();\n $new_sucs.show();\n $('textarea').each(function() {\n this.value = ''\n });\n edit = '';\n }\n var wait = 15,\n submit_val = $submit.val();\n function countdown() {\n if (wait > 0) {\n $submit.val(wait);\n wait--;\n setTimeout(countdown, 1000);\n } else {\n $submit.val(submit_val).attr('disabled', false).fadeTo('slow', 1);\n wait = 15;\n }\n }\n function grin(a) {\n var b;\n a = \" \" + a + \" \";\n if (document.getElementById(comment) && document.getElementById(comment).type == \"textarea\") {\n b = document.getElementById(comment)\n } else {\n return false\n }\n if (document.selection) {\n b.focus();\n sel = document.selection.createRange();\n sel.text = a;\n b.focus()\n } else if (b.selectionStart || b.selectionStart == \"0\") {\n var c = b.selectionStart;\n var d = b.selectionEnd;\n var e = d;\n b.value = b.value.substring(0, c) + a + b.value.substring(d, b.value.length);\n e += a.length;\n b.focus();\n b.selectionStart = e;\n b.selectionEnd = e\n } else {\n b.value += a;\n b.focus()\n }\n }<\/pre>\n\n\n\n\u4e0a\u9762\u7684\u4ee3\u7801\u6709\u4e9b\u9009\u62e9\u5668\u662f\u9488\u5bf9\u6211\u81ea\u5df1\u7684\u4e3b\u9898\u7684\uff0c\u6240\u4ee5\u4ec5\u4f9b\u53c2\u8003\uff0c\u8fd9\u4e2a\u4e0d\u91cd\u8981\u3002\u91cd\u70b9\u662f\u5f53\u5404\u79cd\u53d8\u91cf\u8d4b\u503c\u5b8c\u6bd5\u540e\uff0c\u90a3\u4e00\u53e5$(document).on(\"submit\", commentform, <\/code>\uff0c\u8fd9\u4e2a\u662f\u5173\u952e\uff0c\u610f\u601d\u662f\u8fd9\u4e2aon\u65b9\u6cd5\u628asubmit\u4e8b\u4ef6\u5192\u6ce1\u7ed1\u5b9a\u5230\u4e86document\u4e0a\uff0c\u8fd9\u4e2a\u65f6\u5019submit\u4e8b\u4ef6\u91cc\u9762\u7684\u6240\u6709\u52a8\u4f5c\u5c31\u4e0d\u4f1a\u53d7\u5230\u9875\u9762ajax\u52a0\u8f7d\u7684\u5f71\u54cd\u3002\u4f60\u53ef\u4ee5\u6ce8\u610f\u5230\u4e0a\u9762\u6709\u4e00\u53e5$('#'+comment).after(txt1 + txt2);<\/code> \u8fd9\u4e2a\u662f\u5728\u63d0\u4ea4\u8bc4\u8bba\u65f6\u663e\u793a\u7684loading\u63d0\u793a\u6587\u5b57\uff0c\u5b83\u6ca1\u6709\u88ab\u5305\u542b\u5728submit\u4e8b\u4ef6\u91cc\u9762\uff0c\u6240\u4ee5\u5b83\u662f\u53d7\u5230\u9875\u9762ajax\u52a0\u8f7d\u5f71\u54cd\u7684\uff01\u4e5f\u5c31\u662f\u8bf4\uff1a\u9875\u9762ajax\u52a0\u8f7d\u540e\uff0c\u4f60\u70b9\u51fb\u8bc4\u8bba\u63d0\u4ea4\u6309\u94ae\uff0c\u6b64\u65f6\u4e0d\u4f1a\u663e\u793aloading\u63d0\u793a\u6587\u5b57\uff0c\u4f46\u5374\u80fd\u8fdb\u884cajax\u8bc4\u8bba\u63d0\u4ea4\u3002\u5982\u679c\u4f60\u628a\u8fd9\u6bb5\u63d0\u793a\u653e\u8fdbsubmit\u91cc\u9762\u53bb\uff0c\u90a3\u4e48\u6574\u4e2a\u8bc4\u8bbaajax\u5c31\u548c\u9875\u9762ajax\u5b8c\u5168\u76f8\u4e92\u72ec\u7acb\u4e86\uff0c\u5b83\u4eec\u53ef\u4ee5\u4e92\u4e0d\u5f71\u54cd\uff0c\u5b8c\u5168\u517c\u5bb9\u3002<\/p>\n\n\n\n
\n\n\n\n\u53e6\u5916\uff0c\u4f60\u53ef\u80fd\u6ce8\u610f\u5230\u5728$(document).on(\"submit\", commentform, <\/code>\u4e0a\u4e00\u53e5\u6ce8\u91ca\u662f\u8fd9\u6837\u7684$(commentform).submit(<\/code>\uff0c\u8fd9\u8868\u793a\u4f60\u6ca1\u6709\u7528on\u65b9\u6cd5\u5c06submit\u5192\u6ce1\u5230document\u4e4b\u4e0a\uff0c\u6b64\u65f6\u8fd9\u5c31\u548c\u4e0a\u9762\u90a3\u4e2aloading\u63d0\u793a\u6587\u5b57\u662f\u4e00\u6837\u7684\uff0c\u6574\u4e2a\u8bc4\u8bbaajax\u5c31\u4f1a\u53d7\u5230\u9875\u9762ajax\u7684\u5f71\u54cd\u3002\u90a3\u4e48\u5982\u679c\u4e0d\u7528on\u65b9\u6cd5\uff0c\u5e94\u8be5\u600e\u4e48\u517c\u5bb9\uff1f\u770b\u4e0b\u9762\u7684\u4ee3\u7801\uff1a<\/p>\n\n\n\nvar theme_dir = $('head #default-css').attr('href').split('style.css')[0]; \/\/ \u4e3b\u9898\u8def\u5f84 \uff0c\u4ee5style.css\u5206\u5272href\uff0c\u7b2c\u4e00\u6bb5\u5c31\u662f\u4e3b\u9898\u8def\u5f84\n\/**\n * WordPress jQuery-Ajax-Comments v1.3 by Willin Kan.\n * URI: http:\/\/kan.willin.org\/?p=1271\n *\/\n$(document).ready(function() {\n ajaxComt();\n});\nfunction ajaxComt(){\n var commentform = '#comment_form', \/\/ \u00d7\u00d7\u00d7 form\u8868\u5355id\n comment = 'c_tarea', \/\/ \u00d7\u00d7\u00d7 textarea \u7684id \u4e0d\u5e26#\n commentlist = 'comment-list', \/\/ \u00d7\u00d7\u00d7 \u8bc4\u8bba\u5217\u8868ul\u6216ol\u7684class\uff0c\u4e0d\u5e26\u70b9\n respond = '#respond', \/\/ \u00d7\u00d7\u00d7 \u8bc4\u8bba\u63d2\u5165\u4f4d\u7f6e\uff0c\u63d2\u5165\u5728\u8fd9\u4e2aid\u4e4b\u524d\n homeUrl = document.location.href.match(\/http:\\\/\\\/([^\\\/]+)\\\/\/i)[0], \/\/ \u4e3b\u9875\u5730\u5740\uff0c\u7528\u4e8e\u4e0b\u9762\u7684\u63d0\u4ea4\u51fd\u6570\n txt1 = '<div id=\"loading\" class=\"text-info\"> \u6b63\u5728\u63d0\u4ea4, \u8bf7\u7a0d\u5019...<\/div>',\n txt2 = '<div id=\"error\">#<\/div>',\n txt3 = '\"><div class=\"text-success\"> OK !',\n edt1 = ' \u5237\u65b0\u9875\u9762\u4e4b\u524d\u60a8\u53ef\u4ee5<a rel=\"nofollow\" class=\"comment-reply-link\" href=\"#edit\" onclick=\\'return addComment.moveForm(\"',\n edt2 = ')\\'>\u518d\u6b21\u7f16\u8f91\u8bc4\u8bba<\/a><\/div>',\n cancel_edit = '\u53d6\u6d88\u7f16\u8f91',\n edit,\n num = 1,\n $comments = $('#response'), \/\/ \u8bc4\u8bba\u6570\n $cancel = $('#cancel-comment-reply-link'),\n cancel_text = $cancel.text(),\n $submit = $(commentform+ '#submit');\n $submit.attr('disabled', false),\n $body = (window.opera) ? (document.compatMode == \"CSS1Compat\" ? $('html') : $('body')) : $('html,body'),\n comm_array = [];\n comm_array.push('');\n $('#'+comment).after(txt1 + txt2); \/\/ \u00d7\u00d7\u00d7 textarea\u7684id\u6216class\n $('#loading').hide();\n $('#error').hide();\n \/\/ \u8bc4\u8bba\u63d0\u4ea4\n$(commentform).submit( \/\/ \u975e\u52a8\u6001\u7ed1\u5b9a\n\/\/ $(document).on(\"submit\", commentform, \/\/ \u52a8\u6001\u7ed1\u5b9a\n function() {\n if (edit) $('#'+comment).after('<input type=\"text\" name=\"edit_id\" id=\"edit_id\" value=\"' + edit + '\" style=\"display:none;\" \/>');\n $submit.attr('disabled', true).fadeTo('slow', 0.5);\n $('#loading').slideDown();\n $.ajax({\n url: theme_dir + '\/comt-ajax.php',\n data: $(this).serialize() ,\n type: $(this).attr('method'),\n error: function(request) {\n $('#loading').slideUp();\n $(\"#error\").slideDown().html(request.responseText);\n setTimeout(function() {\n $submit.attr('disabled', false).fadeTo('slow', 1);\n $('#error').slideUp();\n },\n 3000);\n },\n success: function(data) {\n $('#loading').hide();\n comm_array.push($('#'+comment).val());\n $('textarea').each(function() {\n this.value = ''\n });\n var t = addComment,\n cancel = t.I('cancel-comment-reply-link'),\n temp = t.I('wp-temp-form-div'),\n respond = t.I(t.respondId),\n post = t.I('comment_post_ID').value,\n parent = t.I('comment_parent').value;\n \/\/ \u589e\u52a0\u8bc4\u8bba\u6570\n if (!edit && $comments.length) { \n n = parseInt($comments.text().match(\/\\d+\/)); \/\/ \u5339\u914d\u6570\u5b57\n $comments.text($comments.text().replace(n, n + 1));\n }\n \/\/ \u8bc4\u8bba\u663e\u793a\n new_htm = '\" id=\"new_comm_' + num + '\"><\/';\n new_htm = (parent == '0') ? ('\\n<ol style=\"clear:both;\" class=\"'+commentlist+'\" ' + new_htm + 'ol>') : ('\\n<ul class=\"children' + new_htm + 'ul>');\n ok_htm = '\\n<div class=\"ajax-notice\" id=\"success_' + num + txt3;\n div_ = (document.body.innerHTML.indexOf('div-comment-') == -1) ? '': ((document.body.innerHTML.indexOf('li-comment-') == -1) ? 'div-': '');\n ok_htm = ok_htm.concat(edt1, div_, 'comment-', parent, '\", \"', parent, '\", \"respond\", \"', post, '\", ', num, edt2);\n ok_htm += '<\/span><span><\/span>\\n';\n ok_htm += '<\/div>\\n';\n if($('#comments .comment-list').length>0){ \/\/ \u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u00d7\u975e\u5d4c\u5957\u8bc4\u8bba\u65f6\uff0c\u65b0\u8bc4\u8bba\u663e\u793a\u63d2\u5165\u7684\u4f4d\u7f6e\uff08\u6309\u81ea\u5df1\u7684\u559c\u597d\u4fee\u6539\u663e\u793a\u4f4d\u7f6e\uff09\n $('#comments .comment-list').before(new_htm);\n } else{\n $('#respond').after(new_htm);\n }\n $('#new_comm_' + num).append(data);\n $('#new_comm_' + num + ' li').append(ok_htm);\n $body.animate({scrollTop: $('#new_comm_' + num).offset().top - 200},900);\n countdown();\n num++;\n edit = '';\n $('*').remove('#edit_id');\n cancel.style.display = 'none';\n cancel.onclick = null;\n t.I('comment_parent').value = '0';\n if (temp && respond) {\n temp.parentNode.insertBefore(respond, temp);\n temp.parentNode.removeChild(temp)\n }\n }\n });\n return false;\n });\n addComment = {\n moveForm: function(commId, parentId, respondId, postId, num) {\n var t = this,\n div,\n comm = t.I(commId),\n respond = t.I(respondId),\n cancel = t.I('cancel-comment-reply-link'),\n parent = t.I('comment_parent'),\n post = t.I('comment_post_ID');\n if (edit) exit_prev_edit();\n num ? (t.I(comment).value = comm_array[num], edit = t.I('new_comm_' + num).innerHTML.match(\/(comment-)(\\d+)\/)[2], $new_sucs = $('#success_' + num), $new_sucs.hide(), $new_comm = $('#new_comm_' + num), $new_comm.hide(), $cancel.text(cancel_edit)) : $cancel.text(cancel_text);\n t.respondId = respondId;\n postId = postId || false;\n if (!t.I('wp-temp-form-div')) {\n div = document.createElement('div');\n div.id = 'wp-temp-form-div';\n div.style.display = 'none';\n respond.parentNode.insertBefore(div, respond)\n } ! comm ? (temp = t.I('wp-temp-form-div'), t.I('comment_parent').value = '0', temp.parentNode.insertBefore(respond, temp), temp.parentNode.removeChild(temp)) : comm.parentNode.insertBefore(respond, comm.nextSibling);\n $body.animate({scrollTop: $('#respond').offset().top - 180},400);\n if (post && postId) post.value = postId;\n parent.value = parentId;\n cancel.style.display = '';\n cancel.onclick = function() {\n if (edit) exit_prev_edit();\n var t = addComment,\n temp = t.I('wp-temp-form-div'),\n respond = t.I(t.respondId);\n t.I('comment_parent').value = '0';\n if (temp && respond) {\n temp.parentNode.insertBefore(respond, temp);\n temp.parentNode.removeChild(temp);\n }\n this.style.display = 'none';\n this.onclick = null;\n return false;\n };\n try {\n t.I(comment).focus();\n }\n catch(e) {}\n return false;\n },\n I: function(e) {\n return document.getElementById(e);\n }\n };\n function exit_prev_edit() {\n $new_comm.show();\n $new_sucs.show();\n $('textarea').each(function() {\n this.value = ''\n });\n edit = '';\n }\n var wait = 15,\n submit_val = $submit.val();\n function countdown() {\n if (wait > 0) {\n $submit.val(wait);\n wait--;\n setTimeout(countdown, 1000);\n } else {\n $submit.val(submit_val).attr('disabled', false).fadeTo('slow', 1);\n wait = 15;\n }\n }\n function grin(a) {\n var b;\n a = \" \" + a + \" \";\n if (document.getElementById(comment) && document.getElementById(comment).type == \"textarea\") {\n b = document.getElementById(comment)\n } else {\n return false\n }\n if (document.selection) {\n b.focus();\n sel = document.selection.createRange();\n sel.text = a;\n b.focus()\n } else if (b.selectionStart || b.selectionStart == \"0\") {\n var c = b.selectionStart;\n var d = b.selectionEnd;\n var e = d;\n b.value = b.value.substring(0, c) + a + b.value.substring(d, b.value.length);\n e += a.length;\n b.focus();\n b.selectionStart = e;\n b.selectionEnd = e\n } else {\n b.value += a;\n b.focus()\n }\n }\n}\n\/\/ end Ajax\u8bc4\u8bba<\/pre>\n\n\n\n\u4ee3\u7801\u7684\u6838\u5fc3\u5185\u5bb9\u548c\u524d\u9762\u662f\u4e00\u6837\u7684\uff0c\u53ea\u4e0d\u8fc7\u6211\u5c06\u6574\u6bb5\u8bc4\u8bba\u4ee3\u7801\u5199\u6210\u4e86\u4e00\u4e2aajaxComt()<\/code>\u51fd\u6570\uff0c\u4e5f\u5c31\u662f\u5c06\u4ee3\u7801\u7528function ajaxComt(){...}<\/code>\u5305\u4f4f\uff0c\u53ef\u4ee5\u770b\u5230\uff0c\u6b64\u65f6submit\u4e8b\u4ef6\u5e76\u975e\u52a8\u6001\u7ed1\u5b9a\uff0c\u53ea\u8981\u8fd9\u6837<\/p>\n\n\n\n$(document).ready(function() {\n ajaxComt();\n});<\/pre>\n\n\n\n\u5c31\u548c\u539f\u6765\u4e0d\u7528\u51fd\u6570\u5305\u4f4f\u7684\u65f6\u5019\u6ca1\u4ec0\u4e48\u533a\u522b\u4e86\u3002\u90a3\u4e48\u8fd9\u4e2aajaxComt()<\/code>\u51fd\u6570\uff0c\u5c31\u662f\u6211\u4eec\u653e\u5728\u9875\u9762ajax\u56de\u8c03\u91cc\u9762\u91cd\u65b0\u52a0\u8f7d\u7684\u4e1c\u897f\u3002ajax\u65b9\u6cd5\u91cc\u9762\u4f1a\u6709\u51e0\u4e2a\u6267\u884c\u5148\u540e\u7684\u53c2\u6570\uff0cbeforeSend\u3001success\u3001complete \uff0c\u6211\u4eec\u53ef\u4ee5\u628a\u5b83\u653e\u5728complete\u91cc\u9762\uff1a<\/p>\n\n\n\ncomplete: function() { \/\/ \u9875\u9762ajax\u5b8c\u6210\u540e\u52a0\u8f7d\n ajaxComt();\n}<\/pre>\n\n\n\n\u8fd9\u6837\u5c31\u548c\u52a8\u6001\u7ed1\u5b9a\u6ca1\u4ec0\u4e48\u533a\u522b\u4e86\u3002\u8bf4\u6cd5\u7684\u533a\u522b\u4ece\u6211\u4e2a\u4eba\u89d2\u5ea6\u6765\u770b\u5c31\u662f\uff1a\u524d\u8005\u5c5e\u4e8e\u5192\u6ce1\u7ed1\u5b9a\uff0c\u9875\u9762ajax\u548c\u8bc4\u8bbaajax\u662f\u4e92\u4e0d\u5f71\u54cd\u7684\uff1b\u540e\u8005\u5c5e\u4e8e\u5148\u540e\u6267\u884c\uff0c\u9875\u9762ajax\u5148\u6267\u884c\u5b8c\u6bd5\u518d\u6267\u884c\u4e00\u904d\u8bc4\u8bbaajax \u3002<\/p>\n\n\n\n
\u7b2c\u56db\u90e8\u5206<\/h2>\n\n\n\n
\u539f\u6587\u6765\u6e90\uff1a<\/strong> http:\/\/www.inlojv.com\/5026.html <\/p>\n\n\n\n\u6559\u7a0b\u8fdb\u884c\u5230\u7b2c\u56db\u5df2\u7136\u663e\u5f97\u6709\u4e9b\u7f57\u55e6\u4e86\uff0c\u672c\u7bc7\u4e3b\u8981\u662f\u672c\u4eba\u8bb0\u5f55\u81ea\u5df1\u9047\u5230\u7684\u4e00\u4e9b\u7ec6\u8282\u95ee\u9898\u548c\u7f51\u4e0a\u7684\u5404\u79cdpjax\u4ee3\u7801\u7248\u672c\uff0c\u6743\u5f53\u8865\u5145\u7bc7\u6765\u770b\u5427\u3002<\/p>\n\n\n\n
\u641c\u7d22ajax\u8868\u5355\u5e8f\u5217\u5316<\/p>\n\n\n\n
\u6700\u8fd1\u60f3\u628a\u4e3b\u9898\u6362\u6210\u7ecf\u5178\u7684twentytwelve<\/code>\uff0c\u4e5f\u8bd5\u7740\u628a\u5b83pjax\u5316\uff0c\u5176\u4e2d\u9047\u5230\u4e00\u4e2a\u641c\u7d22ajax\u7684\u95ee\u9898\uff0c\u6309\u7406\u8bf4\u5176\u4ed6\u4e3b\u9898\u80fd\u5b9e\u73b0\uff0c\u6ca1\u95ee\u9898\uff0c\u8fd9\u4e2a\u4e5f\u5e94\u8be5\u53ef\u4ee5\uff0c\u4f46\u6211\u628a\u4ee3\u7801\u642c\u4e0a\u53bb\u4e4b\u540e\uff0c\u53d1\u73b0\u641c\u7d22ajax\u8fd4\u56de\u6ca1\u6709\u8fd4\u56de\u6b63\u786e\u7684\u9875\u9762\uff0c\u8fd9\u91cc\u9996\u5148\u8981\u8bf4\u7684\u5c31\u662fWordPress\u6b63\u5e38\u60c5\u51b5\u4e0b\u7684\u641c\u7d22\u8bf7\u6c42\u94fe\u63a5\u5e94\u8be5\u662f\u8fd9\u6837\u7684http:\/\/127.0.0.1\/?=xxx<\/code>\uff0cxxx\u8868\u793a\u4f60\u641c\u7d22\u7684\u5173\u952e\u5b57\uff0c\u800c\u7531\u4e8e\u6709\u540e\u7aef\u7684\u5904\u7406\uff08\u4e5f\u5c31\u662f\u6559\u7a0b[\u4e00]\u4e2d\u7684\u201c\u526a\u88c1\u201d\uff09\uff0c\u53d1\u9001\u7ed9ajax\u7684\u8bf7\u6c42\u94fe\u63a5\u4e00\u822c\u662f\u7c7b\u4f3c?ajx=container<\/code>\u8fd9\u6837\u7684\u540e\u7f00\uff08\u5176\u4ed6\u7248\u672c\u6709\u53ef\u80fd\u662f\u8fd9\u6837?action=pjax<\/code>\uff09\uff0c\u90a3\u4e48\u641c\u7d22ajax\u7684\u8bf7\u6c42\u94fe\u63a5\u80fd\u4e0d\u80fd\u8fd9\u6837http:\/\/127.0.0.1\/?=xxx?ajx=container<\/code>\uff1f\u7b54\u6848\u662f\u4e0d\u80fd\u3002\u53ea\u80fd\u628a?\u53f7\u6362\u6210&\u53f7\uff0c\u53d8\u6210\u8fd9\u6837http:\/\/127.0.0.1\/?=xxx&ajx=container<\/code>\uff0c\u6240\u4ee5\u5728\u641c\u7d22ajax\u7684\u8bf7\u6c42\u94fe\u63a5\u4e0a\u8981\u52a0\u4e00\u4e9b\u5224\u65ad\uff0c\u5982\u679c\u662f\u641c\u7d22\uff0c\u90a3\u4e48\u5f97\u6539\u4e00\u6539\u94fe\u63a5\u9644\u52a0\u7684\u53c2\u6570\u5f62\u5f0f\u3002<\/p>\n\n\n\n
\n\n\n\n\u4ee5\u4e0a\u53ea\u662f\u4e00\u4e2a\u7ec6\u8282\uff0c\u6211\u5728\u4fee\u6539twentytwelve\u65f6\u6ca1\u6709\u8fd4\u56de\u5e94\u6709\u7684\u9875\u9762\uff0c\u628a\u641c\u7d22\u94fe\u63a5http:\/\/127.0.0.1\/?=xxx&ajx=container<\/code>\u76f4\u63a5\u8f93\u5165\u5230\u6d4f\u89c8\u5668\u6253\u5f00\uff0c\u53d1\u73b0\u4e5f\u4e0d\u662f\u641c\u7d22\u7ed3\u679c\u9875\u9762\uff0c\u627e\u4e86\u534a\u5929\u624d\u53d1\u73b0\u662fform\u8868\u5355\u5e8f\u5217\u5316\u7684\u95ee\u9898\uff0c$.ajax()<\/code>\u65b9\u6cd5\u6709\u51e0\u4e2a\u53c2\u6570\uff0c\u5176\u4e2d\u6211\u4eec\u8981\u628a\u5e8f\u5217\u5316\u7684\u8868\u5355\u4fe1\u606f\u653e\u5165\u5230ajax\u65b9\u6cd5\u7684data\u53c2\u6570\u5185\u3002\u8d4b\u503c data = $('#searchform').serialize();<\/code> \u3002\u5176\u4e2d#searchform\u662fform\u8868\u5355\u7684id<\/p>\n\n\n\n
<\/figure><\/div>\n\n\n\n \u4ee5\u4e0a\u53ea\u662f\u4e00\u4e2a\u4f8b\u5b50\uff0c\u6761\u4ef6\u5224\u65ad\u53ef\u4ee5\u6309\u81ea\u5df1\u7684\u601d\u8def\u6765\u505a\u6539\u53d8\u3002\u5982\u6b64\u4e00\u6765\uff0c\u641c\u7d22ajax\u5c31\u6ca1\u6709\u95ee\u9898\u4e86\u3002 <\/p>\n","protected":false},"excerpt":{"rendered":"
wordpress\u5168\u7ad9PJAX\u7cfb\u5217\u6587\u7ae0\u805a\u5408\uff0c\u63a8\u8350\u53bb\u539f\u6587\u7684\u8bc4\u8bba\u533a\u770b\u770b\uff0c\u80af\u5b9a\u6536\u83b7\u4e0d\u5c11<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[185,204],"collection":[],"class_list":["post-12605","post","type-post","status-publish","format-standard","hentry","tag-wp-development"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.npc.ink\/wp-json\/wp\/v2\/posts\/12605"}],"collection":[{"href":"https:\/\/www.npc.ink\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.npc.ink\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.npc.ink\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.npc.ink\/wp-json\/wp\/v2\/comments?post=12605"}],"version-history":[{"count":0,"href":"https:\/\/www.npc.ink\/wp-json\/wp\/v2\/posts\/12605\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.npc.ink\/wp-json\/wp\/v2\/media?parent=12605"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.npc.ink\/wp-json\/wp\/v2\/categories?post=12605"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.npc.ink\/wp-json\/wp\/v2\/tags?post=12605"},{"taxonomy":"collection","embeddable":true,"href":"https:\/\/www.npc.ink\/wp-json\/wp\/v2\/collection?post=12605"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}