Home > Web Front-end > JS Tutorial > Solve the error that blog posts cannot be commented after WordPress uses CDN_javascript skills

Solve the error that blog posts cannot be commented after WordPress uses CDN_javascript skills

WBOY
Release: 2016-05-16 15:25:35
Original
1863 people have browsed it

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++ ;
}
Copy after login

Add:

js_url = js_url.replace('CDN地址','你的域名');
Copy after login

This will solve the problem.

For example:

js_url = js_url.replace('jb51.b0.upaiyun.com','jb51.net');
Copy after login

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],'你的域名');
Copy after login

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? !

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template