---
title: "jQuery 模拟异步实现"
author: "alask2011"
date: "2014-09-30T14:14:06Z"
tags: []
categories: ["Web前端"]
slug: "jquery"
draft: false
lastmod: "2014-09-30T14:15:52Z"
id: 2124140
url: "https://aleywang.iteye.com/blog/2124140"
---

今天找美工帮我封装了一下js的异步，我js太臭了


```js

<script type="text/javascript">
  //顺序必须先收在发
  $(document).on('msg',function(e,data){//收
  		b(data);
  });
  
  $(document).trigger('msg',a());//发
  
  $(document).trigger('msg',a2());//发
  
  
  function a2(){
	  console.log('a2 log');
	  return "a2";
  }
  function a(){
	  console.log('a log');
	  return "a";
  }
  
  function b(){
	  console.log(arguments);
  }
  </script>


```