Code Monkey home page Code Monkey logo

jquery-ajax-file-upload's Introduction

jQuery-Ajax-File-Upload

Plugin to add support for file uploads using jQuery $.ajax()

##What is this? All this plugin does is:

  1. Grabs the files from file fields on change events and adds the data to an array.
  2. On form submit it does a pre-ajax call to the back-end with the file post data.
  3. After uploading, information about those files is passed back and appended to a normal $.ajax() call.

Usage

It's easy enough to use, just include it on your page and attach it to your form with:

$('#myform').fileUpload();

You can pass the following parameters to it:

$('#myform').fileUpload({
	uploadData    : { 'extra_data' : 'blah' }, // Append POST data to the upload
	submitData    : { 'moar_extra_data' : 'blah' }, // Append POST data to the form submit
	uploadOptions : { dataType : 'json' }, // Customise the parameters passed to the $.ajax() call on uploads. You can use any of the normal $.ajax() params
	submitOptions : { dataType : 'json' }, // Customise the parameters passed to the $.ajax() call on the form submit. You can use any of the normal $.ajax() params
	before	      : function(){}, // Run stuff before the upload happens
	beforeSubmit  : function(uploadData){ console.log(uploadData); return true; }, // access the data returned by the upload return false to stop the submit ajax call
	success       : function(data, textStatus, jqXHR){ console.log(data); }, // Callback for the submit success ajax call
	error 	      : function(jqXHR, textStatus, errorThrown){ console.log(jqXHR); }, // Callback if an error happens with your upload call or the submit call
	complete      : function(jqXHR, textStatus){ console.log(jqXHR); } // Callback on completion
});

jquery-ajax-file-upload's People

Contributors

abban avatar

Watchers

James Cloos avatar Hector Alvarado Basantes 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.