Description

This example shows how to disable Ajax form submission.

live demo

Source Code

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
 /**
 * Form - Ajax Disabled
 * @package jqmPhp
 * @filesource
 */
 
 /**
 * Include the jqmPhp class.
 */
 include '../lib/jqmPhp.php';
 
 /**
 * Create a new jqmPhp object.
 */
 $j = new jqmPhp();
 
 /**
 * Create a new jqmPage object.
 */
 $p = new jqmPage('ajax-disabled');
 $p->title('Ajax Disabled');
 $bt = $p->header()->addButton('', 'index.php#', 'a', 'home', false, false, true);
 $bt->rel('external')->attribute('data-iconpos', 'notext');
 $p->addContent('<h1>Form</h1>');
 
 if(isset($_REQUEST['username'])) {
 $p->addContent('<p style="padding:20px;">Wrong username or password.</p>');
 }
 
 /**
 * Create a new jqmForm object.
 */
 $form = new jqmForm('form1');
 $form->action('form-ajax-disabled.php')->method('post');
 $form->add(new jqmInput('username', 'username', 'text', '', 'Username', '', true));
 $form->add(new jqmInput('password', 'password', 'password', '', 'Password', '', true));
 $form->add(new jqmInput('submit', 'submit', 'submit', 'submit', '', 'b', true));
 /**
 * Disable Form Ajax
 */
 $form->attribute('data-ajax', 'false');
 
 /**
 * Add the page to jqmPhp object.
 */    
 $p->addContent($form);
 
 /**
 * Adding Source Code Links.
 */
 $p->addContent('<p>&nbsp;</p>');
 $list = new jqmListview();
 $list->inset(true)->dividerTheme('a');
 $list->addDivider('Source Code');
 $li = $list->addBasic('form-ajax-disabled.php', 'form-ajax-disabled.php.txt', '', true);
 $li->rel('external')->target('_blank');
 $p->addContent($list);
 
 /**
 * Add the page to jqmPhp object.
 */
 $j->addPage($p);
 
 /**
 * Generate the HTML code.
 */
 echo $j;
?>
live demo