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
+63-36Lines changed: 63 additions & 36 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ AjaxChimp is a jQuery plugin that lets you ajaxify your mailchimp form.
4
4
5
5
Use this if you hate the jarring transition to the mailchimp website upon submitting an email address to mailchimp.
6
6
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.)
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 4 years that I know of, and probably more.)
8
8
9
9
10
10
## Install
@@ -15,18 +15,18 @@ Just add the script to your webpage (along with jQuery ofcourse). Get it here:
**Note**: Developed with 1.9.1, but it should work with earlier versions. If it does or does not work with a particular version, please open an issue on github.
28
+
**Note**: Developed with 2.1.4, but it should work with earlier versions. If it does or does not work with a particular version, please open an issue on github.
29
+
30
30
31
31
## Use
32
32
@@ -36,7 +36,7 @@ bower install ajaxchimp
36
36
$('form-selector').ajaxChimp();
37
37
```
38
38
39
-
## Label
39
+
## Error / Success messages
40
40
41
41
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.
42
42
@@ -59,25 +59,30 @@ $('#mc-form').ajaxChimp({
59
59
60
60
## Options
61
61
62
-
### Callback
62
+
### Callbacks
63
+
64
+
Optionally, you can specify a callback with either method to run after the ajax query to mailchimp succeeds or fails.
63
65
64
-
Optionally, you can specify a callback with either method to run after the
65
-
ajax query to mailchimp succeeds or fails.
66
+
The form element that triggered the ajax call is also passed in to the callbacks as the last argument.
66
67
67
68
```js
68
-
$('form-selector').ajaxChimp({
69
+
var formAjaxChimp =$('form-selector').ajaxChimp({
69
70
callback: callbackFunction
70
71
});
71
-
```
72
72
73
-
The JSONP response from mailchimp will be passed to the callback function
To display custom messages, override the default english translations.
107
+
108
+
Notice the use of `$1`, `$2` etc. These are regular expression groups from the original messages for the parts that are dynamic, such as the email address. You can omit them if you want to use a constant message.
100
109
101
-
For success and error messages in different languages:
110
+
For e.g., to change the success message:
111
+
112
+
```js
113
+
$.ajaxChimp.translations.en= {
114
+
success:'Why not say this instead, for the email address $1',
115
+
}
116
+
117
+
```
118
+
119
+
### Multiple language support
102
120
103
121
- Specify the language as an option.
104
122
- Include `jquery.ajaxchimp.langs.js` in the html file
105
123
106
-
107
124
```js
108
125
$('form-selector').ajaxChimp({
109
126
language:'es'
@@ -116,29 +133,39 @@ You can also add custom translations just for your website:
116
133
117
134
```js
118
135
$.ajaxChimp.translations.es= {
119
-
'submit':'Grabación en curso...',
120
-
0:'Te hemos enviado un email de confirmación',
121
-
1:'Por favor, introduzca un valor',
122
-
2:'Una dirección de correo electrónico debe contener una sola @',
123
-
3:'La parte de dominio de la dirección de correo electrónico no es válida (la parte después de la @:)',
124
-
4:'La parte de usuario de la dirección de correo electrónico no es válida (la parte antes de la @:)',
125
-
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'
136
+
submit:'Grabación en curso...',
137
+
success:'Te hemos enviado un email de confirmación $1',
138
+
error: {
139
+
1:'Por favor, introduzca un valor',
140
+
2:'Una dirección de correo electrónico debe contener una sola @',
141
+
3:'La parte de dominio de la dirección de correo electrónico no es válida (la parte después de la @: $1)',
142
+
4:'La parte de usuario de la dirección de correo electrónico no es válida (la parte antes de la @: $1)',
143
+
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',
144
+
6:'blah blah',
145
+
7:'blah',
146
+
}
126
147
}
127
148
```
128
149
129
150
The mapping to english for mailchimp responses and the submit message are as follows:
130
151
131
152
```js
132
153
// Submit Message
133
-
// 'submit': 'Submitting...'
134
-
135
-
// Mailchimp Responses
136
-
// 0: 'We have sent you a confirmation email'
137
-
// 1: 'Please enter a value'
138
-
// 2: 'An email address must contain a single @'
139
-
// 3: 'The domain portion of the email address is invalid (the portion after the @: )'
140
-
// 4: 'The username portion of the email address is invalid (the portion before the @: )'
141
-
// 5: 'This email address looks fake or invalid. Please enter a real email address'
154
+
// submit: 'Submitting...'
155
+
156
+
// Success Message
157
+
// success: 'Please confirm by clicking on the link we just sent to $1.'
158
+
159
+
// Error Messages
160
+
// errors: {
161
+
// 1: 'Please enter a value',
162
+
// 2: 'An email address must contain a single @',
163
+
// 3: 'The domain portion of the email address is invalid (the portion after the @: $1 )',
164
+
// 4: 'The username portion of the email address is invalid (the portion before the @: $1 )',
165
+
// 5: 'This email address looks fake or invalid. Please enter a real email address',
166
+
// 6: 'Too many subscribe attempts for this email address. Please try again in about 5 minutes.',
0 commit comments