{"id":19490914,"url":"https://github.com/pandao/jquery-ajaxqueuer","last_synced_at":"2025-02-25T19:43:23.137Z","repository":{"id":23946297,"uuid":"27327913","full_name":"pandao/jquery-ajaxqueuer","owner":"pandao","description":"jquery plugin for ajax queue","archived":false,"fork":false,"pushed_at":"2014-12-04T12:53:44.000Z","size":212,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-08T08:45:48.698Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pandao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-30T07:13:41.000Z","updated_at":"2023-09-08T16:52:32.000Z","dependencies_parsed_at":"2022-08-06T00:16:07.555Z","dependency_job_id":null,"html_url":"https://github.com/pandao/jquery-ajaxqueuer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pandao%2Fjquery-ajaxqueuer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pandao%2Fjquery-ajaxqueuer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pandao%2Fjquery-ajaxqueuer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pandao%2Fjquery-ajaxqueuer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pandao","download_url":"https://codeload.github.com/pandao/jquery-ajaxqueuer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240738088,"owners_count":19849546,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T21:14:45.576Z","updated_at":"2025-02-25T19:43:23.110Z","avatar_url":"https://github.com/pandao.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"jQuery.ajaxQueuer\n=================\n\njquery plugin for ajax queue，jQuery Ajax队列扩展。\n\n####参数说明\n\n\t$.ajaxQueuer([ajax队列], {配置});\n\n配置项(具有优先级)：\n\n\ttype\t\tString\t\t请求方式，默认为GET\n\tasync\t\tBoolean\t\t是否为异步，默认为false，即同步\n\ttimeout\t\tNumber(ms)\t设置请求超时时间（毫秒），此设置将覆盖全局设置\n\tnamePrefix\tString\t\t队列名称前缀，默认为'ajaxQueuer'\n\najax队列是一个数组，由$.ajax方法的配置选项组成($.ajaxQueuer删除和增添一部分)：\n\n\tasync\t\t\t\t\t\t\t\t\t\t\tBoolean\t\t在$.ajaxQueuer中默认为false，为同步队列，每个请求都需要上一个请求成功才能开始；\n\tbefore(queue)\t\t\t\t\t\t\t\t\tFunction\t在$.ajax()执行之前的处理，例如： loading；\n\tbeforeSend(xhr, queue, ajaxOptions)\t\t\t\tFunction\t发送请求前可修改 XMLHttpRequest 对象的函数，如添加自定义 HTTP 头；\n\tcache\t\t\t\t\t\t\t\t\t\t\tBoolean\t\t默认为true，dataType为script和jsonp时默认为false；\n\tcomplete(xhr, ts, queue, ajaxOptions)\t\t\tFunction\t请求完成后回调函数，请求成功或失败之后均调用；\n\tcontentType\t\t\t\t\t\t\t\t\t\tString\t\t发送信息至服务器时内容编码类型，默认为\"application/x-www-form-urlencoded\"；\n\tcrossDomain\t\t\t\t\t\t\t\t\t\tBoolean\t\t默认为同域请求，false；跨域请求为true，例如JSONP请求；\n\tdata\t\t\t\t\t\t\t\t\t\t\tKey/Value\t发送到服务器的数据，默认为{}\n\tdataType\t\t\t\t\t\t\t\t\t\tString\t\t服务器返回的数据类型，默认为\"text html\"\n\terror(xhr, status, queue, ajaxOptions)\t\t\tFunction\t请求失败时调用此函数\n\theaders\t\t\t\t\t\t\t\t\t\t\tKey/Value\t设置HTTP头的键值对，默认为{}\n\tjsonp\t\t\t\t\t\t\t\t\t\t\tString\t\t在一个jsonp请求中重写回调函数的名字，默认为\"callback\"；\n\tindex\t\t\t\t\t\t\t\t\t\t\tInteger\t\t队列序号\n\tname\t\t\t\t\t\t\t\t\t\t\tString\t\t队列名称ID\n\tpriority\t\t\t\t\t\t\t\t\t\tInteger\t\t优先级数字，在异步方式下，数值越大优先执行和发送，但不一定是最先完成；\n\tprocessData\t\t\t\t\t\t\t\t\t\tBoolean\t\t通过data选项传递进来的数据，如果是一个对象，都会处理转化成一个查询字符串，默认为true\n\tstatus\t\t\t\t\t\t\t\t\t\t\tString\t\t请求完成的状态，例如\"error\"、\"success\"、\"timeout\"；\n\tstatusCode\t\t\t\t\t\t\t\t\t\tKey/Value\t一组数值的HTTP代码和函数对象，当响应时调用了相应的代码，默认为{}；\n\tsuccess(data, status, xhr, queue, ajaxOptions)\tFunction\t请求成功后的回调函数\n\ttimeout\t\t\t\t\t\t\t\t\t\t\tNumber\t\t设置请求超时时间（毫秒），此设置将覆盖全局设置；\n\ttype\t\t\t\t\t\t\t\t\t\t\tString\t\t请求方式，默认为GET\n\turl\t\t\t\t\t\t\t\t\t\t\t\tString\t\t发送请求的目标地址\n\n成员方法和属性：\n\n\t# 当前执行的队列序号\n\tnowIndex\n\n\t# 获取配置选项\n\tsettings\n\n\t# 队列ID\n\tqid\n\n\t# 队列数组\n\tqueue\n\n\t# 队列总数\n\tcount\n\n\t# 追加队列\n\tadd([ajax队列数组])\n\tadd({ajax队列})\n\n\t# 开始执行队列, 依据配置同步或异步\n\trun()\n\n\t# 开始执行队列, 同步方式\n\tsynch()\n\n\t# 开始执行队列, 异步方式\n\tasync()\n\n\t# 清除整个队列\n\tflush()\n\n\t# 获取整个队列对象\n\tgetQueues()\n\n\t# 只执行队列中的最后一个\n\tlast()\n\n####使用方法\n\t\t\n\t\u003cscript type=\"text/javascript\" src=\"js/jquery.min.js\"\u003e\u003c/script\u003e\n\t\u003cscript type=\"text/javascript\" src=\"../src/jquery.ajaxqueuer.js\"\u003e\u003c/script\u003e\n\t\u003cscript type=\"text/javascript\"\u003e\n\t\tvar ajaxQueuer = $.ajaxQueuer([\n\t\t\t{ \n\t\t\t\turl : \"ajax.get.php?no=1\", \n\t\t\t\terror : function(xhr, status) {\n\t\t\t\t\tconsole.error(this.name, \"请求错误：\", xhr, status);\n\t\t\t\t},\n\t\t\t\tsuccess : function(data, status, xhr, queue, ajaxOptions) {\n\t\t\t\t\tconsole.log(this.name, \"GET\", data, ajaxOptions);\n\t\t\t\t},\n\t\t\t\tcomplete : function(xhr, status) {\n\t\t\t\t\t// this指向队列选项\n\t\t\t\t\tconsole.log(this.name, \"请求完成：\", xhr, status);\t\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\turl : \"ajax.get.php\", \n\t\t\t\tdata : \"temp=\"+Math.random(),\n\t\t\t\tsuccess : function(data, status, xhr, queue, ajaxOptions) {\n\t\t\t\t\tconsole.log(this.name, \"GET\", data, ajaxOptions);\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\turl : \"ajax.get.php?timeout\", \n\t\t\t\tdata : \"temp=\"+Math.random(), \n\t\t\t\tpriority : 3,\n\t\t\t\tstatusCode : {\n\t\t\t\t\t0: function() {\n\t\t\t\t\t\t$(\"#debuger\")[0].innerHTML += '\u003cspan style=\"color:red;\"\u003e请求超时：status=\u003e0, '+this.url+'\u003c/span\u003e\u003cbr/\u003e';\n\t\t\t\t\t},\n\t\t\t\t\t404: function() { \n\t\t\t\t\t\t$(\"#debuger\")[0].innerHTML += '\u003cspan style=\"color:red;\"\u003e请求失败：status=\u003e404, '+this.url+'\u003c/span\u003e\u003cbr/\u003e';\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tbefore : function() {\n\t\t\t\t\tconsole.log('priority', this.priority);\n\t\t\t\t},\n\t\t\t\terror : function(xhr, status) {\n\t\t\t\t\tconsole.error(this.name, \"GET\", \"请求失败\", xhr, status);\n\t\t\t\t},\n\t\t\t\tsuccess : function(data, status, xhr, queue, ajaxOptions) {\n\t\t\t\t\tconsole.log(this.name, \"GET\", data, ajaxOptions);\n\t\t\t\t}\n\t\t\t}\n\t\t], {\n\t\t\ttype \t: \"GET\",\n\t\t\tasync\t: true,\n\t\t\ttimeout\t: 3000\n\t\t});\n\n\t\tajaxQueuer.add([\n\t\t\t{\n\t\t\t\turl : \"ajax.jsonp.php\",\n\t\t\t\tdata : {temp : Math.random()},\n\t\t\t\tdataType : \"json\",\n\t\t\t\tpriority : 2,\n\t\t\t\tsuccess : function(data, status, xhr, queue, ajaxOptions) {\n\t\t\t\t\t$(\"#debuger\")[0].innerHTML += \"\u003cp\u003egetJSON =\u003e ajax.jsonp.php =\u003e\" + JSON.stringify(data) + \"\u003c/p\u003e\";\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\turl : \"ajax.jsonp.php\",\n\t\t\t\tdata : {temp : Math.random()},\n\t\t\t\tdataType : \"json\",\n\t\t\t\tpriority : 2,\n\t\t\t\tsuccess : function(data, status, xhr, queue, ajaxOptions) {\n\t\t\t\t\t$(\"#debuger\")[0].innerHTML += \"\u003cp\u003egetJSON =\u003e ajax.jsonp.php =\u003e\" + JSON.stringify(data) + \"\u003c/p\u003e\";\n\t\t\t\t}\n\t\t\t}\n\t\t]).add({\n\t\t\turl : \"ajax.post.php\",\n\t\t\ttype : \"POST\",\n\t\t\tpriority : 1,\n\t\t\tbefore : function() {\n\t\t\t\tconsole.log('priority', this.priority);\n\t\t\t},\n\t\t\tdata : {temp : Math.random()}, \n\t\t\tsuccess : function(data, status, xhr, queue, ajaxOptions) { \n\t\t\t\tconsole.log('getJSON =\u003e ajax.post.php =\u003e', this.url, \"\\n\", data);\n\t\t\t\t$(\"#debuger\")[0].innerHTML += \"\u003cp\u003egetJSON =\u003e ajax.post.php =\u003e\" + data + \"\u003c/p\u003e\";\n\t\t\t}\n\t\t}).run(); \t\n\t\u003c/script\u003e\n\n同时也支持在Require.js和Sea.js中使用：\n\t\n\t# 在Sea.js中使用\n\t\u003cscript type=\"text/javascript\" src=\"js/sea.js\"\u003e\u003c/script\u003e\n\t\u003cscript type=\"text/javascript\"\u003e\n\t\tseajs.config({\n\t\t\tbase : \"./js\",\n\t　　　　alias : {\n\t　　　　　　\"jquery\": \"jquery.min\"\n\t　　　　}\n\t　　});\n\n\t\tseajs.use(\"./js/main\");\n\t\u003c/script\u003e\n\n\t# main.js\n\tdefine(function(require, exports, module) {\t\n\t\tvar $ = require('jquery');\n\t\trequire('../../src/jquery.ajaxqueuer'); \n\t\trequire('../js/jquery.ajaxqueuer.demo');  \n\t});\n\n\t# 在Require.js中使用\n\t\u003cscript type=\"text/javascript\" src=\"js/require.min.js\"\u003e\u003c/script\u003e\n\t\u003cscript type=\"text/javascript\"\u003e\n\t\trequire.config({\n\t　　　　paths: {\n\t　　　　　　\"jquery\": \"js/jquery.min\"\n\t　　　　}\n\t　　});\n\n\t　　require(['../src/jquery.ajaxqueuer', './js/jquery.ajaxqueuer.demo'], function () {   \n\t\t});\n\t\u003c/script\u003e\n\n####License\n\nThe MIT License (MIT)\n\nCopyright (c) 2014 Pandao","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpandao%2Fjquery-ajaxqueuer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpandao%2Fjquery-ajaxqueuer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpandao%2Fjquery-ajaxqueuer/lists"}