@@ -3,6 +3,8 @@ jquery-maxsubmit
3
3
4
4
jQuery plugin to detect if too many form items will be submitte for the server to cope with.
5
5
6
+ ## Introduction
7
+
6
8
Some appications, such as ecommerce sites, can have administration forms that submit well
7
9
over a thousand parameters. PHP, by default, is set to accept only one thousand parameters
8
10
and so some of the submitted data can get lost.
@@ -16,13 +18,19 @@ Luckily the maximum number of accepted parameters can be changed in php.ini The
16
18
many site owners have no idea this needs to be done until it is too late and their
17
19
WooCommerce store has lost half its product variations.
18
20
21
+ ## Plugin Purpose
22
+
19
23
What this jQuery plugin attempts to do, is warn the site administrator before a form is
20
24
submitted, on the client (browser) side, and give the administrator a chance to cancel the
21
25
submit and change the settings on the server. It does this by counting how many items
22
26
will be submitted in a form (it does this, hopefully, intellidently by taking into account
23
27
all the form item types and selected values). The plugin is given the maximum number of
24
28
items the server will accept when the page is generated, so it has a number to compare to.
25
29
30
+ ## Implementation
31
+
32
+ ### Client-side JavaScript
33
+
26
34
The simplest way to implement the check is to use this JavaScript in the jQuery ready()
27
35
function:
28
36
@@ -33,6 +41,8 @@ be POSTed by the form. Additional settings allow you to modify the confirm box t
33
41
or replace the standard confirm box with something more ambitious, such as a jquery.ui
34
42
dialog. You can target specific forms with different settings if you wish.
35
43
44
+ ### Server-side Code
45
+
36
46
The server limit (1000 in this case) needs to be passed into the script above. This can
37
47
be found with a simple PHP function like this:
38
48
@@ -65,7 +75,7 @@ be found with a simple PHP function like this:
65
75
That runs on the server and provides the server settings to insert into the JavaScript
66
76
initialisation, and will return 1000 by default on most PHP servers.
67
77
68
- A simnple demo (index.php in this project) is running here: [ http://www.acadweb.co.uk/maxsubmit/ ]
78
+ A simple demo (index.php in this project) is running here: [ http://www.acadweb.co.uk/maxsubmit/ ]
69
79
70
80
The jQuery plugin and the PHP function are the two building blocks. I intend to wrap them into a
71
81
simple WordPress plugin next. Just install it along with your WooCommerce plugin, and it will stop
0 commit comments