<form action="/" jasync> <input type="submit" /> </form>
the form is sent asynchronously <input type="file" href="/" multiple jasync /> <div type="file" href="/" multiple jasync> </div> <div href="/" jasync dropfile> </div>
files boot asynchronously <a href="/" jasync data="year=2013&month=5" class="send"> </a>
data is sent asynchronously $( '.send' ).bind( 'jasync.success', function( e, data ) { // data - } );
<form action="/" jasync="message"> <input type="submit" /> </form>
{ messages: { { type: 'replace', elem: '#myElem', html: ' ' }, { type: 'append', elem: '.myClass', html: ' ' }, { type: 'delete', elem: '.delElems' }, { callback: 'alert', callback_params: [ '' ] }, { type: 'openPopap', // jquery.message.ajax.js , html: '...' } } }
{ url: ' ' }
$( 'form' ).bind( 'jasync.beforeSend', function( ) { var form = $( this ); if( !form.isValid() ) { form.jasync( 'stop', true ); // } // form.jasync( { 'addData': { count: 20, typesend: 'send jasync' }, 'dataType': 'json' // } ); } );
header( 'Content-type: text/json' ); echo json_encode( array( 'messages' => array( array( 'type' => 'replace', 'elem' => '#myElem', 'html' => ' ' ), array( 'type' => 'append', 'elem' => '.myClass', 'html' => ' ' ), array( 'type' => 'delete', 'elem' => '.delElems' ), array( 'callback' => 'alert', 'callback_params' => array('') ) ) ) );
$message = AsyncResponse::getInstance(); $message ->add( AsyncResponse::REPLACE, '#myElem', ' ' ) ->add( AsyncResponse::APPEND, '.myClass', ' ' ) ->add( AsyncResponse::DELETE, '.delElems' ) ->addCallback( 'console.log', '', '!!!' ); //->openPopup( '' ) $message->end();
<a href="/image/save/" name="image" multiple jasync> </a>
<div href="/image/save/" name="image" dropfile jasync> </div>
$( document ).on( 'jasync.beforeSend', 'a[type=file]', function( e, imgs ) { // $( this ).jasync( { 'addData': { count: 20 }, 'maxSize': 20000 // } ); if( imgs.nosupport ) { $( '#answer' ).html( ' iframe, ...' ); return; } for( var i = 0, l = imgs.length; i < l; i++ ) { imgs[ i ] // .bind( 'jasync.load', function( e, file ) { // file - base64 $( 'body' ).append( '<img src="' + file + '" />' ); $( this ) // .bind( 'jasync.uploadProgress', function( e, percent, obj ) { // percent - } ) // .bind( 'jasync.success', function( e, data ) { //console.log( data ); } ) // .bind( 'jasync.error', function() { } ); } ); } } ).on( 'jasync.success', 'a[type=file]', function( e, data ) { // iframe $( '#answer' ).html( data ); } );
Source: https://habr.com/ru/post/177069/
All Articles