躺在沙灘上的小豬

          快樂的每一天

          Moo.ajax: 1.3kb for all your asynchronous needs

          http://ajaxian.com/archives/mooajax-13kb-for-all-your-asynchronous-needs
          Valerio Proietti, the creator of Moo.fx, has now created a micro library for Ajax, moo.ajax.

          I noticed many of you requested if it would have been possible to use the full prototype, instead of the lite one I provided with the full download of moofx, to use its ajax capabilities along with the effects. Sure you can, but wouldn’t it be cooler if there was a more lightweigt one?

          Just to continue my mission in small javascripting, I have arranged this moo.ajax, in just 1.3kb of uncompressed sweetness.

          read more for instructions, or download the script. As always, any comments/corrections/suggestions are highly appreciated.

          moo.ajax is a very simple ajax class, to be used with prototype.lite from moo.fx. It’s roughly based on the prototype one, so their usage are very similar.

          The request
          to make any request just call

          new ajax(url, options);


          The options
          method: choose either post or get. The default is post.
          posyBody postBody: if you choose post as method, you can write parameters here.
          onComplete: a function that will be fired when your request is complete. The request object will be passed as a parameter of the function.
          update: an dom element or an element’s id. This element will be filled with the request’s responsetext.
          An example
          This will call my script.php via post, setting as parameter sleep=3. When the request is complete I want an alert with the response text, and I want an element to be updated with the responsetext as well.

          new ajax ('sleep.php', {postBody: 'sleep=3', update: $('myelementid'), onComplete: myFunction});
          function myFunction(request){
            alert(request.responseText);
          }

          posted on 2006-01-20 09:31 martin xus 閱讀(397) 評論(0)  編輯  收藏

          主站蜘蛛池模板: 杂多县| 沐川县| 锡林浩特市| 莆田市| 秦皇岛市| 青海省| 阜南县| 普兰店市| 雷州市| 文山县| 武山县| 乌恰县| 西藏| 民勤县| 绵竹市| 巴青县| 衡东县| 胶州市| 驻马店市| 竹溪县| 临城县| 庆城县| 淮阳县| 怀远县| 江门市| 鸡东县| 玛沁县| 新密市| 大化| 兴业县| 湾仔区| 赣州市| 工布江达县| 灵宝市| 广汉市| 云龙县| 陇川县| 民乐县| 温宿县| 吴忠市| 瓮安县|