{"id":16493874,"url":"https://github.com/echosoar/gax","last_synced_at":"2026-05-14T10:34:31.534Z","repository":{"id":103981799,"uuid":"61697334","full_name":"echosoar/gax","owner":"echosoar","description":"Promise mode ajax component,compatible with most major browsers","archived":false,"fork":false,"pushed_at":"2017-04-11T15:02:04.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-11T22:17:46.562Z","etag":null,"topics":["ajax","gax","jsonp","promise"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/echosoar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-22T07:13:45.000Z","updated_at":"2021-12-28T05:50:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"5d2c3483-8bcb-445b-bdac-9e0988c02e13","html_url":"https://github.com/echosoar/gax","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/echosoar%2Fgax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echosoar%2Fgax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echosoar%2Fgax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echosoar%2Fgax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/echosoar","download_url":"https://codeload.github.com/echosoar/gax/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241335595,"owners_count":19946086,"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":["ajax","gax","jsonp","promise"],"created_at":"2024-10-11T14:10:59.001Z","updated_at":"2026-05-14T10:34:31.496Z","avatar_url":"https://github.com/echosoar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#GAX : Glory Asynchronous XmlHttpRequest\n***\n通用Ajax，支持链式调用，跨域，POST和GET，内嵌Fetch API支持。\n###基本方法 Basic Method\n\n#####构造方法 Gax(url)\n\u003e url : 请求的地址\n\n\u003e 此方法返回一个Gax对象。\n\n```javascript\nGax(\"http://iwenku.net\");\n```\n***\n##### 配置设置 set(key,value)\n\u003e key ：要设置配置选项的键\n\n\u003e value : 要设置配置选项的值\n\n\u003e 此方法返回一个Gax对象。\n\n\u003e 默认配置 ：返回内容类型（type），可设置为json、xml；超时时间（timeout），默认为0即没有超时；超时回调函数（ontimeout），默认为空函数；跨域方法（com），默认为jsonp，需要在服务器生成的内容中调用GaxJsonp方法。\n```javascript\nGax(\"http://iwenku.net\").set(\"type\",\"json\");\n```\n***\n##### HTTP头信息设置 header(key,value)\n\u003e key ：要设置的头\n\n\u003e value : 要设置的头内容\n\n\u003e 此方法返回一个Gax对象。\n\n```javascript\nGax(\"http://iwenku.net\").set(\"type\",\"json\").header(\"Content-Type\",\"application/x-www-form-urlencoded\");\n```\n***\n##### GET请求方法 get(dataObject)\n\u003edataObject是一个对象，是要传向目标URL的内容。\n\n\u003e 此方法返回一个Gax对象。\n\n```javascript\nGax(\"http://iwenku.net\").set(\"type\",\"json\").header(\"Content-Type\",\"application/x-www-form-urlencoded\").get({name:\"gax\"});\n```\n***\n##### POST请求方法 post(dataObject)\n\u003edataObject是一个对象，是要传向目标URL的内容。\n\n\u003e 此方法返回一个Gax对象。\n\n```javascript\nGax(\"http://iwenku.net\").post({name:\"gax\"});\n```\n***\n##### 成功回调函数 success(callback(data[,args]))\n\u003ecallback是一个函数，当请求成功时会将返回的数据根据配置中的type来进行处理，然后传入callback。\n\n\u003eargs中存储着耗时等信息。\n\n\u003e 此方法返回一个Gax对象。\n\n```javascript\nGax(\"http://iwenku.net\").get().success(function(data){\n\tconsole.log(data);\n});\n```\n***\n##### 失败回调函数 error(callback(args))\n\u003ecallback是一个函数，在请求失败时执行，args中存储着失败的原因，耗时等信息。\n\n\u003e 此方法返回一个Gax对象。\n\n```javascript\nGax(\"http://iwenku.net\").get().success(function(data){\n\tconsole.log(data);\n}).error(function(args){\n\tconsole.log(args);\n});\n```\n##### jsonp自动回调配置\n\n只要使用set配置了jsonpCallBack的值，Gax就会自动去处理jsonp的请求，发出的请求后面会携带callback=${jsonpCallBack}\n\ncallback也可以进行设置，使用set设置jsonpCallBackKey就可以了\n\n```javascript\nGax(\"http://api.asilu.com/ip/\").set(\"jsonpCallBackKey\",\"callback\").set(\"jsonpCallBack\",\"ip\").get().success(function(data) {\n\tconsole.log(arguments);\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fechosoar%2Fgax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fechosoar%2Fgax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fechosoar%2Fgax/lists"}