Skip to content

Instantly share code, notes, and snippets.

@shamsbd71
Last active August 30, 2015 06:45
Show Gist options
  • Save shamsbd71/adbc9cdb9e3bbf2b4c61 to your computer and use it in GitHub Desktop.
Save shamsbd71/adbc9cdb9e3bbf2b4c61 to your computer and use it in GitHub Desktop.
Joomla Ajax Form Submit from Module. help link:https://github.com/Joomla-Ajax-Interface
/**
* @package Custom use
* @author Abu Huraira Bin Aman shams.bd71@gmail.com
* @license GNU General Public License version 3 or later; see LICENSE.txt
* @version 1.0.0
*/
(function($){
$(document).ready(function(){
$('#myform').submit(function() {
var value = $(this).serializeArray(),
$.ajax({
type : 'POST',
data : value,
beforeSend: function(){
$('#myform .submit').addClass('loading');
},
success: function (response) {
$('#myform .message').fadeOut().html(response).fadeIn().delay(1000);
$('#myform .submit').removeClass('loading');
}
});
return false;
});
});
})(jQuery);
<?php
/**
* @package Custom use
* @author Abu Huraira Bin Aman shams.bd71@gmail.com
* @license GNU General Public License version 3 or later; see LICENSE.txt
* @version 1.0.0
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
?>
<form id="myform" name="myform">
<button type="submit" class="submit">Submit</button>
<div class="message"></div>
<input type="hidden" name="option" value="com_ajax" />
<input type="hidden" name="module" value="xpertcontact" />
<input type="hidden" name="format" value="raw" />
<?php echo JHtml::_('form.token'); ?>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment