/wp-common/products.php?term_id=4&page=1

var currentAjax;
var total = 0;
function getAjaxData(term_id, page = 1) {
currentAjax = $.ajax({
type: "GET",
url: "/wp-common/products.php?term_id=" + term_id + "&page=" + page,
dataType: "json",
success: function (res) {
if (res) {
total = res.total;
if (total > 0) {
var products = res.products;
var subHtml = `
${products.map(
value => `
<li>
<a href="${value.url}">
<div class="img-wrap">
<img src="${value.image}"
alt="${value.alt}">
</div>
<h4>${value.name}</h4>
</a>
</li>`
).join('')}`;
$('.p02-8-s1 .text ul').html(subHtml);
if (total > 1) {
$('.mml-pages').mmlpage(page, total, {
prev: '<i class="fa fa-chevron-left" aria-hidden="true"></i>',
next: '<i class="fa fa-chevron-right" aria-hidden="true"></i>',
href: 'javascript:;',
"click": function (page) {
$('.p02-8-s1 .text ul').empty().html("<li>loading products...</li>");
getAjaxData(term_id,page);
}
});
$('.p02-1-s1 .prev').click(function () {
if (currentAjax) {
currentAjax.abort();
}
$('.p02-8-s1 .text ul').empty().html("<li>loading products...</li>");
page = page > 1 ? page - 1 : 1;
getAjaxData(term_id,page);
});
$('.p02-1-s1 .next').click(function () {
if (currentAjax) {
currentAjax.abort();
}
$('.p02-8-s1 .text ul').empty().html("<li>loading products...</li>");
page = page < total ? page + 1 : total;
getAjaxData(term_id,page);
});
}
if ( total < 1) {
$('.p02-8-s1 .text ul').empty().html("<li>no data</li>");
}
}
}
}
});
}
var term_id = $('.p02-8-s1 .tab .active').attr('data-term_id');
if ($(window).width() <= 540) {
getAjaxData(0, page = 1);
} else {
getAjaxData(term_id, page = 1);
}
$(window).resize(function () {
if ($(window).width() <= 540) {
getAjaxData(0, page = 1);
} else {
getAjaxData(term_id, page = 1);
}
});

后端异步接口url的更多相关文章

  1. layui 富文本 图片上传 后端PHP接口

    <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/ ...

  2. NodeJS中常见异步接口定义(get、post、jsonp)

    越来越多的人在使用nodeJS,作为一门服务端语言,我们不可避免的要写异步接口(ajax和jsonp).再次强调ajax和jsonp是两个概念,但是由于jquery的封装,使这两种异步接口的调用方式, ...

  3. Python怎么测试异步接口

    当业务处理比较耗时时, 接口一般会采用异步处理的方式, 这种异步处理的方式又叫Future模式. 一般流程 当你请求一个异步接口,接口会立刻返回你一个结果告诉你已经开始处理,结果中一般会包含一个任务i ...

  4. Postman实现数字签名,Session依赖, 接口依赖, 异步接口结果轮询

    Script(JS)为Postman赋予无限可能 基于Postman 6.1.4 Mac Native版 演示结合user_api_demo实现 PS 最近接到任务, 要把几种基本下单接口调试和持续集 ...

  5. Django-Scrapy生成后端json接口

    Django-Scrapy生成后端json接口: 网上的关于django-scrapy的介绍比较少,该博客只在本人查资料的过程中学习的,如果不对之处,希望指出改正: 以后的博客可能不会再出关于djan ...

  6. Python Flask后端异步处理(一)

    Flask是Python中有名的轻量级同步Web框架,但是在实际的开发中,可能会遇到需要长时间处理的任务,此时就需要使用异步的方式来实现,让长时间任务在后台运行,先将本次请求的相应状态返回给前端,不让 ...

  7. 任意文件下载漏洞的接口URL构造分析与讨论

    文件下载接口的URL构造分析与讨论 某学院的文件下载接口 http://www.****.edu.cn/item/filedown.asp?id=76749&Ext=rar&fname ...

  8. 如何使用 Python 编写后端 API 接口

    如何使用 Python 编写后端 API 接口 get API Python3 # coding:utf-8 import json # ModuleNotFoundError: No module ...

  9. 使用egg.js开发后端API接口系统

    什么是Egg.js Egg.js 为企业级框架和应用而生,我们希望由 Egg.js 孕育出更多上层框架,帮助开发团队和开发人员降低开发和维护成本.详细的了解可以参考Egg.js的官网:https:// ...

随机推荐

  1. linux make: *** No targets specified and no makefile found. Stop.

    [root@localhost Python-]# ./configure checking build system type... x86_64-unknown-linux-gnu checkin ...

  2. Concurrent - 线程池

    原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/11426981.html ThreadPoolExecutor底层方法参数: @param corePo ...

  3. boost smart pointer

    1. boost::scoped_ptr is a smart pointer that is the sole owner of a dynamically allocated object and ...

  4. 用 GetEnvironmentVariable 获取常用系统环境变量

    以前曾用 GetWindowsDirectory.GetSystemDirectory.GetTempPath 等函数获取系统常用文件夹; 也用过 SHGetSpecialFolderLocation ...

  5. ssm项目配置多个数据源

    在项目中到一些问题,一些查询模块需要链接另一个数据库,这时,就可以配置两个数据源进行操作. 1.创建jdbc.properties jdbc.url = jdbc:mysql://localhost: ...

  6. java动态代理的原理

    在许多mvc框架中,经常用到注解来实现面向切面(aop)的编程.面向切面编程,可以对业务逻辑中各部分进行分离,提高程序的重用性,降低各逻辑业务部分的耦合度. jdk中利用反射原理使用Proxy类对对象 ...

  7. Hive HiveQL基础知识及常用语句总结

    基础语句 CREATE DROP 建表.删表 建表 -------------------------------------- -- 1. 直接建表 ------------------------ ...

  8. java集合框架面试要点整理

  9. 16. Django基础数据访问

    如果我们想使用Django对数据库进行访问,我们可以使用django自带的shell. 进入blog目录,打开cmd命令窗口,输入python manage.py shell,如下图所示: 插入数据 ...

  10. 用Processing生成屏保(二)

    代码 1: class TPoint 2: { 3: public TPoint(int _x, int _y) { 4: super(); 5: this._x = _x; 6: this._y = ...