npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mmRequest

v0.4.5

Published

The HTTP client for avalon.js

Downloads

5

Readme

mmRequest

mmRequest 为异步 HTTP(AJAX)请求提供了解决方案。就像 jQuery.ajax() 所做的那样。

mmRequest 是 avalon 三柱臣之一(另外两个是 route 和 animation)。

安装

bower 安装:

bower install mm-request

从npm 安装

npm install mmRequest --save

开始

Avalon 遵循 AMD 规范。在引入 avalon.jsmmRequest.js 之后,你便可以像下面这样使用 mmRequest 了:

require(['./mmRequest'], function(avalon) {
    avalon.ajax({
        url: '/foobar'
    });
});

文档

mmRequest 提供了如下方法:

/*
 * avalon.ajax 需要传入一个拥有类似 url、type、dataType、type 等属性的对象参数;
 * avalon.ajax 的行为类似于 jQuery.ajax。
 */
avalon.ajax(opts)

/*
 * 其他一些简写方法:
 */
avalon.get( url [, data ] [, success(data, textStatus, XHR) ] [, dataType ] )
avalon.post( url [, data ] [, success(data, textStatus, XHR) ] [, dataType ] )
avalon.upload( url, form [,data] [, success(data, textStatus, XHR)] [, dataType])
avalon.getJSON( url [, data ] [, success( data, textStatus, jqXHR ) ] )
avalon.getScript( url [, success(script, textStatus, jqXHR) ] )

avalon可以在配置对象使用headers来指定头部, 
```javascript
avalon.ajax({
	type: "POST",
	url: "your-path",
	headers: {
      xxx: "yyy"

   },
   success: function(){}

})

/*

  • 一些有用的工具类方法: */ // 将一个对象转换成一个用于 URL 中传递请求参数的字符串 avalon.param(obj) // 将一个用于 URL 中传递请求参数的字符串转换成一个对象 avalon.unparam(str) // 将一个元素中的表单元素编码成字符串 avalon.serialize(element)

更多信息请参考 `/docs`。

示例
----

安装依赖:

cd demo/ && npm install


如果你很幸运地在中国,试试 [cnpm](http://cnpmjs.org/)。

开启服务:

cd ../ && npm start


现在,打开你的浏览器访问 `http://127.0.0.1:3000` 这个地址,你将会看到例子。你可以在 `demo/bin/www` 这个文件中配置端口。

在测试跨域请求之前,你需要模拟一个跨域的环境。你可以将这个项目复制到另外的路径并用另一个端口开启服务作为后端服务(这个例子中,后端服务的端口是 `9000`)。

祝你愉快。:grin:

贡献
------------

请在 `src/` 目录下开发相应的模块。

mmRequest 使用 [gulp](http://gulpjs.com/) 构建,请先安装依赖模块:

npm install


然后开启 `gulp`,监听 `src/` 下的变化并自动合并文件至 `public/`:

gulp


更新日志
------------

见 [CHANGELOG.md](CHANGELOG.md)