This article mainly introduces how to solve the problem that WordPress cannot comment after using CDN. It also reminds you to pay attention to the jQuery version support of WordPress, need a friend can refer to the comments-ajax.js In the cdn cache, many people encounter problems that cannot (use ajax) reply. In this regard, my previous practice is to prohibit cdn from caching this file, so that I do not want.
The original solution is, after the 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 address', 'Your domain name ');
This will solve this problem.
For example:
js_url = js_url.replace('jb51.b0.upaiyun.com','jb51.net');
To this end, I made some convenient changes and added the following content after:
Var dm = js_url.match (/http: \/([^ \/] +) \ // I); js_url = js_url.replace (dm [1], 'Your domain name ');
In this way, you only need to enter your own domain name to view and enter the cdn domain name. This is not an example.
Of course, do not forget to refresh the cache. Update the comments-ajax.js file under cdn
After Wordpress is upgraded to 3.6, jQuery uses version 1.10.2 and uses jQuery Migrate to be compatible with the old jQuery code. That is, multiple requests.
This jQuery Migrate can be used to detect and restore deleted or outdated APIs in jQuery1.9 or later versions, but there are multiple calls. Does this remind us. Should I use the new jQuery function as soon as possible ?!