Giter VIP home page Giter VIP logo

tinyajaxform's Introduction

tinyAjaxForm.js

Overview

tinyAjaxForm is a small and simple library that transforms regular forms into ajax forms.

Dependencies: jQuery

Compared to ajaxForm

Cons: No support for file uploads. Doesn't have several ajaxForm features

Pros: Really tiny. It's 1.5k (0.8k minified). To compare, ajaxForm is 40k! (17k minified)

Example

<form id="show-code" action="tinyAjaxForm.js">
    <input type="submit" value="Show code">
</form>
<div id="code-display"></div>

...

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="tinyAjaxForm.min.js"></script>
<script>
$('#show-code').tinyAjaxForm($('#code-display'));   // shortcut
</script>

Clicking submit will fill the div with the contents of tinyAjaxForm.js. If Javascript is disabled it will disgrade gracefully, and act like a normal form.

Usage

Usage:

$(form-selector).tinyAjaxForm(options)

$(form-selector).tinyAjaxForm(successCallback)

$(form-selector).tinyAjaxForm(targetHtmlElementSelector)

'options' is a dictionary object with these attributes:

  • success: a function to call if the ajax query is successful (same as jQuery)

  • error: a function to be call if it failed (same as jQuery)

  • dataType: What data to expect back (text, json, ... same as jQuery)

  • beforeSubmit(params, form, options):

    A function to call before submitting the form. It may manipulate the params object before the form is submitted. If it returns 'false', the submit is aborted.

Tips

If you want to replace ajaxForm in an existing page, you can place this line right after loading tinyAjaxForm:

jQuery.fn.ajaxForm=jQuery.fn.tinyAjaxForm;

License

MIT

tinyajaxform's People

Contributors

erezsh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.