Unexpected token : in response from mailchimp listSubscribe call

734 views
Skip to first unread message

Ryan Headley

unread,
May 25, 2012, 4:35:31 PM5/25/12
to mailchimp-...@googlegroups.com
I am making the following call via jquery:

I can sign up  just fine and I can read the response that I get from mailchimp via the javascript console, though the javascript console reports an error with the response when I try to do anything with it.

Ex.  If I try to sign up twice with the same email, I'm getting the appropriate error thrown, but it appears to be complaining about its format:
{"error":"em...@addy.com is already subscribed to list Our List. <a href=\"http:\/\/our-company.us4.list-manage.com\/subscribe\/send-email?u=somekeyhere&id=listhere&e=this-looked-secret-too\">Click here to update your profile.<\/a>","code":214}

The error in chrome's console is: Uncaught SyntaxError: Unexpected token :
And it points to us4.mailchimp.api.com:1 (which is the above json response)

Could it be that the the colon in the http string isn't escaped?

Any help would be greatly appreciated. As stated it appears to work, but doing anything in my UI based on that response is impossible at this point if I can't read the data returned.





Notice: The information contained in this message or any attached document is confidential and intended only for individuals to whom it is addressed. If you got this message in error, please inform me immediately using one of the methods above. In some cases, I may ask you to return the documents at my expense. In general, please simply destroy the information at once. Any unauthorized use, distribution, or copying of this information is prohibited.

Ryan Headley

unread,
May 25, 2012, 4:47:21 PM5/25/12
to mailchimp-...@googlegroups.com
I forgot, i can't be the colon in the string because colon's don't need to be escaped...that being said...it clearly doesn't like something...

Ryan Headley

unread,
May 25, 2012, 5:10:16 PM5/25/12
to mailchimp-...@googlegroups.com
Firebug in firefox gives me invalid label and points to {"error": in the response....not sure if that helps.  I'm figuring its something I am doing wrong, but I've tried all day.

jesse

unread,
May 26, 2012, 8:58:21 AM5/26/12
to mailchimp-...@googlegroups.com
You shouldn't be trying to make API calls via javascript. That will require you to expose your API key to anyone hitting the page and you'll also likely run into cross-site scripting issues.

That said, the json returned decodes just fine, so any issue is unlikely related to the API.


jesse

Ryan Headley

unread,
May 26, 2012, 9:18:23 AM5/26/12
to mailchimp-...@googlegroups.com

We will ultimately be going the PHP route, but i am prototyping here to get an understanding and the docs mention doing this for simple tasks, though it wont be our production solution.

That being said, you have verified what i was afraid of in that is most likely the code and not the API but i was to the "grasping at straws point"

--
You received this message because you are subscribed to the Google Groups "MailChimp API Discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mailchimp-api-discuss/-/zlxBwwvK08MJ.
To post to this group, send email to mailchimp-...@googlegroups.com.
To unsubscribe from this group, send email to mailchimp-api-di...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mailchimp-api-discuss?hl=en.
Reply all
Reply to author
Forward
0 new messages