user3100093
user3100093

Reputation: 1

Ajax Mandrill send email on form submit

If i go through this code step by step in firebug it works, but it wont work on button press. Using a button outside form to call it works ok.....It seems that complete: line does not get executed at all.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {

 $('#salji').click(function() {

var testing = false;

      $.ajax({
  type: "POST",
  url: "https://mandrillapp.com/api/1.0/messages/send.json",
  data: {
    'key': 'Vv_8cJDX9*****',
    'message': {
      'from_email': 's****@gmail.com',
      'to': [
          {
            'email': 'd*****@gmail.com',
            'name': 'Test',
            'type': 'to'
          }
        ],
      'autotext': 'true',
      'subject': 'New subject',
      'html': 'YOUR EMAIL CONTENT HERE! YOU CAN USE HTML!'
    }
  },    
complete: function() {
                    testing = true;
                    $('#forma').attr('action', 'http://%SERVERIP%/signup1?%PARAMS%');
                    $('#forma').submit();

        }
 }
)
})
})

</script>


<div class="form1" align="center"><input  class="button" value="#CONTINUE#" name="signup" type="submit" id="salji">

Upvotes: 0

Views: 1268

Answers (1)

Nicekiwi
Nicekiwi

Reputation: 4807

You don't have a form on the page, therefore .submit won't do anything.

Change your DIV to a form and give it the correct ID, "form1" is a class atm.

Upvotes: 2

Related Questions