+ com_asyncform + assets + css -common.css + js -common.js -mootools-1.2.1-core.js + controllers -default.php + models -asyncform.php + views + tmpl -default.php -view.html.php -asyncform.php
asyncform.php
<?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?><?php
defined ( '_JEXEC' ) or die ( 'Restricted access' ) ;
if ( $controller = JRequest :: getVar ( 'controller' ) ) {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . $controller . DS . 'view.html.php' ) ;
}
else {
require_once ( JPATH_COMPONENT . DS . 'controllers' . DS . 'default.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'models' . DS . 'asyncform.php' ) ;
require_once ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'view.html.php' ) ;
}
// Create the controller
$classname = 'AsyncformController' . $controller ;
$controller = new $classname ;
$controller -> execute ( JRequest :: getVar ( 'task' ) ) ;
$controller -> redirect ( ) ;
?>
controllers / default.php
- <? php
- jimport ( 'joomla.application.component.controller' ) ;
- class AsyncformController extends JController {
- function __construct ( $ default = array ( ) ) {
- parent :: __construct ( $ default ) ;
- $ this -> registerDefaultTask ( 'display' ) ;
- $ this -> registerTask ( 'check' , 'check' ) ;
- }
- function cancel ( ) {
- $ this -> setRedirect ( 'index.php' ) ;
- }
- function display ( ) {
- $ view = new AsyncformView ( ) ;
- $ view -> display ( ) ;
- }
- function check ( ) {
- $ isValid = false ;
- $ res [ 'type' ] = '' ;
- $ res [ 'msg' ] = '' ;
- $ res [ 'items' ] = array ( ) ;
- $ name = substr ( JRequest :: getVar ( 'name' ) , 0 , 50 ) ;
- if ( ereg ( '[aaja-Yaa-zA-Z \ -] + $' , $ name ) ) {
- $ res [ 'items' ] [ ] = array ( 'name' => 'name' , 'status' => 1 ) ;
- $ isValid = true ;
- }
- else {
- $ res [ 'items' ] [ ] = array ( 'name' => 'name' , 'status' => 0 ) ;
- $ isValid = false ;
- }
- $ email = strtolower ( substr ( JRequest :: getVar ( 'email' ) , 0 , 50 ) ) ;
- if ( ereg ( '^ [^ 0-9] [a-z0-9 _ \ - \.] + @ [^ 0-9] [az \ - \.] + \. [az] {2,4} $ ' , $ email ) ) {
- $ res [ 'items' ] [ ] = array ( 'name' => 'email' , 'status' => 1 ) ;
- $ isValid = true ;
- }
- else {
- $ res [ 'items' ] [ ] = array ( 'name' => 'email' , 'status' => 0 ) ;
- $ isValid = false ;
- }
- if ( $ isValid ) {
- $ res [ 'type' ] = 'valid' ;
- $ res [ 'msg' ] = 'The form is filled in correctly' ;
- }
- else {
- $ res [ 'type' ] = 'error' ;
- $ res [ 'msg' ] = 'Error!' ;
- }
- echo json_encode ( $ res ) ;
- }
- }
- ?>
models / asyncform.php
- <? php
- jimport ( 'joomla.application.component.model' ) ;
- class AsyncformModel extends JModel {
- }
- ?>
views / default / view.html.php
- <? php
- jimport ( 'joomla.application.component.view' ) ;
- class AsyncformView extends JView {
- public $ message ;
- function __construct ( ) {
- $ this -> addTemplatePath ( JPATH_COMPONENT . DS . 'views' . DS . 'default' . DS . 'tmpl' ) ;
- }
- function display ( $ tpl = null ) {
- // JHTML :: _ ('behavior.mootools');
- $ document = & JFactory :: getDocument ( ) ;
- $ document -> addStyleSheet ( 'components / com_asyncform / assets / css / common.css' ) ;
- $ document -> addScript ( 'components / com_asyncform / assets / js / mootools-1.2.1-core.js' ) ;
- $ document -> addScript ( 'components / com_asyncform / assets / js / common.js' ) ;
- parent :: display ( $ tpl ) ;
- }
- }
- ?>
views / default / tmpl / default.php
- <? php defined ( '_JEXEC' ) or die ( 'Access denied' ) ; ?>
- <div id = "log"> </ div>
- <form id = "frm_asyncform" action = "index.php? option = com_asyncform & task = check & format = raw" method = "post">
- <table>
- <tr>
- <td> Name </ td>
- <td> <input type = "text" name = "name" id = "name" /> </ td>
- </ tr>
- <tr>
- <td> Email </ td>
- <td> <input type = "text" name = "email" id = "email" /> </ td>
- </ tr>
- </ table>
- <input type = "submit" name = "btn_submit" id = "btn_submit" value = "send" />
- </ form>
assets / css / common.css
- .error {
- border : 2px solid # ff0000 ;
- }
- #log {
- padding : 5px ;
- overflow : auto ;
- margin-bottom : 5px ;
- width : 452px ;
- }
- #log .loaded {
- background-color : # ffc0c0 ;
- }
- #log .loaded-success {
- background-color : # c0ffc0 ;
- }
assets / js / common.js
- window. addEvent ( 'domready' , function ( ) {
- $ ( 'frm_asyncform' ) . addEvent ( 'submit' , function ( e ) {
- e. stop ( ) ;
- var log = $ ( 'log' ) . empty ( ) ;
- this . set ( 'send' , {
- method : 'post' ,
- onComplete : function ( response ) {
- var res = JSON. decode ( response ) ;
- res. items . each ( function ( field ) {
- if ( field. status )
- $ ( field. name ) . removeClass ( 'error' ) ;
- else
- $ ( field. name ) . addClass ( 'error' ) ;
- } ) ;
- if ( res. type == 'valid' )
- log. addClass ( 'loaded-success' ) ;
- else
- log. addClass ( 'loaded' ) ;
- log. set ( 'html' , res. msg ) ;
- }
- } ) ;
- this . send ( ) ;
- } ) ;
- } ) ;
Source: https://habr.com/ru/post/55788/
All Articles