WarrenBee
WarrenBee

Reputation: 107

How to return success/failure messages with ajax?

I'm using MailChimp's API and I can successfully subscribe an email address by passing an email address to a specific URL. Once the email is submitted, MailChimp echoes a success or failure code.

Example: myurl.com/[email protected]

What I need help with

My form isn't displaying the success/failure messages that I've based on MailChimps returned codes. What am I doing wrong?

http://jsfiddle.net/WarrenBee/c4MWX/

Upvotes: 0

Views: 399

Answers (2)

Jonathan M
Jonathan M

Reputation: 17461

As long as I'm guessing on comments, I'll guess on an answer. I went to http://yoursite.com/subscribe/[email protected] in my browser. I got this:

Unable to load listSubscribe()! Code=220 Msg="[email protected]" has been banned

So, you've got a problem in your server-side code. It can't load a function named listSubscribe(). Also, regardless, you're not returning stuff in JSON format, but your ajax call is expecting such.

Upvotes: 2

Pointy
Pointy

Reputation: 414086

It's not working because the ajax operation is failing. You're trying to post to a URL in a different domain, and that particular server is not set up to allow that.

Upvotes: 0

Related Questions