我有一个网站在桌面上工作正常,但当我将它运行到移动浏览器特别是chrome。并将书籍添加到愿望清单中需要大约1分钟来处理。它在Firefox中运行良好。
网站链接 - bookwise.co.in
我的代码是:
class BaseClass {
constructor() {
if (this.constructor === BaseClass) {
throw new Error("Can't instantiate abstract class!");
}
}
post(data, success, failure) {
var endpoint = this.endpoint;
showLoader();
$.ajax({
url: SITE_URL + endpoint,
data: data,
type: 'POST',
headers: {
'X-API-KEY': globalUser.accessToken
},
success: function(data) {
hideLoader();
if (typeof(success) == 'function') {
success(data)
}
},
error: function(err) {
hideLoader();
if (typeof(failure) == 'function') {
failure(err)
}
}
});
}
delete(data, success, failure) {
var endpoint = this.endpoint;
showLoader();
$.ajax({
url: SITE_URL + endpoint,
data: data,
type: 'DELETE',
headers: {
'X-API-KEY': globalUser.accessToken
},
success: function(data) {
hideLoader();
if (typeof(success) == 'function') {
success(data)
}
},
error: function(err) {
hideLoader();
if (typeof(failure) == 'function') {
failure(err)
}
}
});
}
}
class Wishlist extends BaseClass {
constructor(endpoint) {
super();
this.endpoint = endpoint ? endpoint : 'wishlist';
}
}
function bindWishListToggle() {
$(".wishlist-toggle-btn").unbind('click').bind('click', function() {
var id = $(this).parents(".similar-book-item").data("id");
var isWishList = $(this).data("wishlist");
var _this = this;
var wishlist = new Wishlist();
var successCb = function() {
$(_this).find("img").attr("src", isWishList ? "assets/images/heartempty.png" : "assets/images/heartfull.png");
$(_this).data("wishlist", !isWishList);
};
var failCB = function(data) {
if (data.status == 401)
$("#myModal").modal();
}
if (isWishList) {
wishlist.delete({
bookId: id
}, successCb, failCB);
} else {
wishlist.post({
bookId: id
}, successCb, failCB);
}
});
}
以上是我的代码我不知道为什么它只发生在chrome中。