casey palmer
Posts: 0
Joined: Tue Mar 18, 2014 6:32 am

mandrill response

Having issues displaying an alert to the response when sending email using mandrill. The email send successfully and I can see it in the Mandrill API log.. here is the response return

[
{
"email": "a href="mailto:bob@aol.com" rel="nofollow"bob@aol.com/a",
"status": "sent",
"id": "91585cf913af4ff487394075111021ef",
"reject_reason": null
},
{
"email": "a href="mailto:sally@ail.com" rel="nofollow"sally@ail.com/a",
"status": "sent",
"id": "fc26c8e30f974e458f204a70ef487350",
"reject_reason": null
}
]

This is what I am trying,
var response = JSON.parse(jqXHR.responseText);

if (response.return[1] == 'sent')
{
alert ('Email sent.');
}

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

mandrill response

Hello,

Please clarify your problem.

casey palmer
Posts: 0
Joined: Tue Mar 18, 2014 6:32 am

mandrill response

Im sorry.. when I try to use the JavaScript to capture the response the application does not display alert and the loader (not sure what is is called) on the screen just spins like the application is doing something but never stops. The mail does get sent successfully.

I have the JavaScript running on completion of the service invocation, should I move it to Success

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

mandrill response

Hi Casey,

Probably it's an error in your JS code not allowing to end the process.

Please give us screen shots from your service and complete event handler where you place you JS code.

Also look in browser console. May be there some errors.

casey palmer
Posts: 0
Joined: Tue Mar 18, 2014 6:32 am

mandrill response

The email is sent successfully when I test the app. Here is the response from the API log in Mandrillapp.com. Do I have to loop through this to get the statuses or can I just get the first status?

Response from Mandrill API
[
{
"email": "a href="mailto:caseympalmer@hotmail.com" rel="nofollow"caseympalmer@hotmail.com/a",
"status": "sent",
"id": "8badfbc5fe2f4177bb57eab1d517775b",
"reject_reason": null
},
{
"email": "a href="mailto:casey.palmer@horiba.com" rel="nofollow"casey.palmer@horiba.com/a",
"status": "sent",
"id": "3c4c63394cf0422cb62473071a7d9b3e",
"reject_reason": null
}
]

My JavaScript:
var response = JSON.parse(jqXHR.responseText);

var status = response.return[1];

if (status == 'sent'){
alert ('Email Sent');
}

Image Image

casey palmer
Posts: 0
Joined: Tue Mar 18, 2014 6:32 am

mandrill response

I also try this mapping of the response and I can not get the response for returned status in a text box.

Example response from Mandrill.

[
{
"email": "a href="mailto:recipient.email@example.com" rel="nofollow"recipient.email@example.com/a",
"status": "sent",
"reject_reason": "hard-bounce",
"_id": "abc123abc123abc123abc123abc123"
}
]

Here is my mapping to try and display the "status" in a text box

Image

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

mandrill response

Hi Casey -

Accordingly to your response you have a wrong code:
pre
var status = response.return[1];
/pre

Please try this code:
pre
var response = JSON.parse(jqXHR.responseText);

//You should see this log in your browser console. Please check it out.
console.log("response = ");
console.log(response);

var status = response[0].status;

console.log("status = " + status);

if(status == 'sent')
alert ('Email Sent');
/pre
Note: Here is test log messages in the code above which is should be removed after service is tested.

casey palmer
Posts: 0
Joined: Tue Mar 18, 2014 6:32 am

mandrill response

Thank you for your help, this did indeed solve my issue..

Return to “Issues”