Solve the problem that WordPress cannot comment after using CDN _ javascript skills

Source: Internet
Author: User
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 ?!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.