Home > Article > Web Front-end > Solve the error that blog posts cannot be commented after WordPress uses CDN_javascript skills
After comments-ajax.js is cached by CDN, many people encounter the problem of being unable to reply (using ajax). In this regard, my previous approach was just to prohibit cdn from caching this file and leave it alone.
The original solution is, at the end of comments-ajax.js:
var i = 0, got = -1, len = document.getElementsByTagName('script').length; while ( i <= len && got == -1){ var js_url = document.getElementsByTagName('script')[i].src, got = js_url.indexOf('comments-ajax.js'); i++ ; }
Add:
js_url = js_url.replace('CDN地址','你的域名');
This will solve the problem.
For example:
js_url = js_url.replace('jb51.b0.upaiyun.com','jb51.net');
To this end, I made some convenient modifications and added:
after "}"var dm = js_url.match(/http:\/\/([^\/]+)\//i); js_url = js_url.replace(dm[1],'你的域名');
That’s it. You save one step to check and fill in the cdn domain name. You only need to fill in your own domain name. I won’t give an example.
Of course, don’t forget to refresh the cache at the end. Update the comments-ajax.js file of cdn
After WordPress was upgraded to 3.6, jQuery used version 1.10.2, and jQuery Migrate was used to be compatible with older jQuery codes. That is, one more request.
This jQuery Migrate can be used to detect and restore APIs that have been deleted or obsolete in jQuery 1.9 or above, but there are just a few more calls. Is this a reminder to us. Want to use new jQuery function features as soon as possible? !