forked from Joomla-Ajax-Interface/Hello-Ajax-World-Module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod_hello_ajax_world.php
42 lines (36 loc) · 1.04 KB
/
mod_hello_ajax_world.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php defined('_JEXEC') or die;
/**
* File mod_hello_ajax_world.php
* Created 1/17/14 12:29 PM
* Author Matt Thomas | [email protected] | http://betweenbrain.com
* Support https://github.com/Joomla-Ajax-Interface/Hello-Ajax-World-Module/issues
* Copyright Copyright (C) 2013 betweenbrain llc. All Rights Reserved.
* License GNU General Public License version 2, or later.
*/
// Include the helper.
require_once __DIR__ . '/helper.php';
// Instantiate global document object
$doc = JFactory::getDocument();
$js = <<<JS
(function ($) {
$(document).on('click', 'input[type=submit]', function () {
var value = $('input[name=data]').val(),
request = {
'option' : 'com_ajax',
'module' : 'hello_ajax_world',
'data' : value,
'format' : 'raw'
};
$.ajax({
type : 'POST',
data : request,
success: function (response) {
$('.status').html(response);
}
});
return false;
});
})(jQuery)
JS;
$doc->addScriptDeclaration($js);
require JModuleHelper::getLayoutPath('mod_hello_ajax_world');