0

I'm using AjaxChimp to use ajax to submit a sign up form to MailChimp.

The issue I have is that I'm using a callback function as in this example here: AJAX Mailchimp signup form integration

but I would like to trap and modify the response text I get back from MailChimp. My code is:

<script type="text/javascript">
        $(function() {
            $('form').ajaxChimp({
                callback: function(response) {
                    $('form .result').text(response.msg);                      
                }
            });
        })
    </script>

Any help in how to do this is very much appreciated. I'm a javascript beginner.

Thanks,

Mark

Community
  • 1
  • 1
MarkG
  • 37
  • 4

2 Answers2

3
<script type="text/javascript">
        $(function() {
            $('form').ajaxChimp({
                callback: function(response) {
                    // u can this change response like
                    response = response + ' foo ' ;
                    $('form .result').text(response.msg);                      
                }
            });
        })
    </script>
Legendary
  • 2,243
  • 16
  • 26
3

You want to modify the response text? Here is an example of concatentation:

<script type="text/javascript">
        $(function() {
            $('form').ajaxChimp({
                callback: function(response) {
                    var modifiedText = "The response was " + response.msg;
                    $('form .result').text(modifiedText);
                }
            });
        })
    </script>

There are many other ways to modify a string. Here are some examples:

http://www.w3schools.com/js/js_string_methods.asp

tedw
  • 451
  • 5
  • 8