I'm playing around with the Trello API and I'm slowly getting the hang of it. I'm stuck on one piece where I manage to create a new card inside a speicifc list, but I'd like to parse the response I get from the "createCard" call e.g. to get the ID of the new card.
Here is my Trello create card post:
Trello.post("cards", { name: "Card Created from MVC", desc: "This is the description of the card.", idList: "??????????" }).done(onCardCreated());
I've omitted the real idList value for secutiry reasons.
I can see the card instantly on my Trello board. The response I get from this call starts like this:
jQuery1510518084118841216_1327764237952({"id":"????","name":"Card Created from MVC","desc":........)
I was expecting to see the JSON returned liked this:
{"id":"????","name":"Card Created from MVC","desc":....}
But in this case, the JSON is wrapped around in this jQuery1510518084118841216_1327764237952 thing.
Can some tell me what the jQuery thing is for, and how do I get to the JSON data inside of it?
Because the request is going to another domain (i.e. api.trello.com), the client-side library is using JSONP.
The library is using jQuery's AJAX calls (with the jsonp dataType), which is why the JSONP callback has a "jQuery" name.
Although the actual response you see includes the JSONP callback, the response from the library that is given to the success callback should just include the JSON.
I would expect that something like this should work:
Trello
.post("cards", { name: "Foo", desc: "Bar", idList:"..."})
.done(function(card) { alert(card.id) })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With