You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+73-24Lines changed: 73 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,11 @@
2
2
3
3
AjaxChimp is a jQuery plugin that lets you ajaxify your mailchimp form.
4
4
5
-
Use this if you hate the jarring transition to the mailchimp website on submitting a mailchimp.
5
+
Use this if you hate the jarring transition to the mailchimp website upon submitting an email address to mailchimp.
6
6
7
7
**Note**: This relies on an undocumented feature at mailchimp that uses JSONP to allow cross-domain ajax to work. You have been warned. (It has however, been around for at least 3 years that I know of, and probably more.)
8
8
9
+
9
10
## Install
10
11
11
12
Just add the script to your webpage (along with jQuery ofcourse). Get it here:
#### Method 2: Use a blank form with an input of type email
38
-
39
39
```js
40
-
$('form-selector').ajaxChimp({
41
-
url:'mailchimp-post-url'
42
-
});
40
+
$.ajaxChimp.init('form-selector');
43
41
```
44
42
45
-
The mailchimp post url will look like this:
46
43
44
+
## Label
45
+
46
+
If a label element is included in the form for the email input, then the success or error message will be displayed in it. A `valid` or `error` class will also be added accordingly.
**Note**: The advantage of using method 1 is that even if ajax or javascript fails, the form will fallback and work as a normal mailchimp form.
52
64
53
-
## Callback
65
+
## Options
66
+
67
+
### Callback
54
68
55
69
Optionally, you can specify a callback with either method to run after the
56
70
ajax query to mailchimp succeeds or fails.
57
71
58
72
```js
59
73
$('form-selector').ajaxChimp({
60
-
callback: callbackfunction,
61
-
url:'mailchimp-post-url'
74
+
callback: callbackfunction
62
75
});
63
76
```
64
77
@@ -72,22 +85,58 @@ function callbackFunction (resp) {
72
85
}
73
86
```
74
87
75
-
##Label
88
+
### URL
76
89
77
-
If a label element is included in the form for the email input, then the success or error message will be displayed in it. A `valid` or `error` class will also be added accordingly.
90
+
You can specify the mailchimp URL to post to (or override the url provided on the form element)
If the language you want is not supported out of the box, or the translations are wrong, open a pull request with the required language and I will add it in. You can also add translations to your js file as follows:
119
+
120
+
```js
121
+
$.ajaxChimp.translations.es = {
122
+
0: 'Te hemos enviado un email de confirmación',
123
+
1: 'Por favor, introduzca un valor',
124
+
2: 'Una dirección de correo electrónico debe contener una sola @',
125
+
3: 'La parte de dominio de la dirección de correo electrónico no es válida (la parte después de la @:)',
126
+
4: 'La parte de usuario de la dirección de correo electrónico no es válida (la parte antes de la @:)',
127
+
5: 'Esta dirección de correo electrónico se ve falso o no válido. Por favor, introduce una dirección de correo electrónico real'
128
+
}
93
129
```
130
+
131
+
The response numbers are as follows:
132
+
133
+
```js
134
+
// Responses
135
+
// 0: 'We have sent you a confirmation email'
136
+
// 1: 'Please enter a value'
137
+
// 2: 'An email address must contain a single @'
138
+
// 3: 'The domain portion of the email address is invalid (the portion after the @: )'
139
+
// 4: 'The username portion of the email address is invalid (the portion before the @: )'
140
+
// 5: 'This email address looks fake or invalid. Please enter a real email address'
0 commit comments