Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Tim's [VERY OLD] Mini JavaScript Library
JavaScript Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
pkg
src
test
README.textile
build.rb
license.txt

README.textile

Tim’s Mini JavaScript Library

github.com/seven1m/mini

An uber lightweight library for building buzzword-compliant beta Web 5.0 applications.

Usage

  1. Download and stick the contents of pkg/ in your app’s javascript directory (the files in src/ contain comments and a bit of whitespace, whereas pkg/ contains minified versions).
  2. Depending on your needs, add one or more <script> tags, e.g. <script type="text/javascript" src="/js/ajax.js"></script>, to your html.

mini.ajax

mini.form.serialize(f)
Serializes all the fields in a form so that they can be passed as a query string in the form “arg1=val1&arg2=val2”.

mini.ajax.x()
The XMLHttpRequest object (or MS equivalent) used for communication

mini.ajax.send(u,f,m,a)
Send a basic Ajax request.

mini.ajax.get(url,func)
Uses a GET request to query the specified url and return a response to the specified function.

mini.ajax.gets(url)
Uses a GET request to query the specified url and return a response synchronously. Use this sparingly, as synchronous calls can lock up the browser.

mini.ajax.post(url,func,args)
Uses a POST request to query the specified url and return a response to the specified function.

mini.ajax.update(url,elm,method,args)
Uses a POST request to query the specified url and insert the result into the specified element.

  • method = GET or POST (default)
  • args = arguments as string (not used if specifying GET — instead pass args with url like this: “url?arg=val”)

mini.ajax.submit(url,frm,elm)
Used in the onsubmit handler of a function. The form is not submitted the usual way; the form is instead serialized using “ajax.serialize” and submitted using “ajax.post”. The result is then inserted into the specified element.

  • frm = form element
  • elm (optional) = element to update with returned content; if blank, returned content will be assumed to be javascript, and will be evaluated
    Example: <form action="fallback/url" onsubmit="mini.ajax.submit('ajax/form/url', this, 'div_to_update');return false;">

mini.form

mini.form.validate(frm)
Use in the onsubmit handler of your form to validate that required fields are completed, e.g. <form onsubmit="return mini.form.validate(this)">
Indicate required fields with class=“required”
Add label.error { color: red; } or similar to your stylesheet so that errored fields will stand out.

Something went wrong with that request. Please try again.