Ajax request errors

28 views
Skip to first unread message

Steve

unread,
Oct 31, 2011, 11:17:04 PM10/31/11
to Yipit API
Hi, I am getting started with the yipit api on my local machine and
trying to make an ajax request to the yipit tags api using jquery1.6.
I am using the jQuery ajax function and if the dataType parameter is
set to json is returns a 200 with no data but if I set the dataType to
jsonp I get and invalid label error but I can see the expected json
response object. The yipit docs indicate everything is returned in
json, any idea where I am going wrong?

Dave Tomback

unread,
Nov 1, 2011, 6:21:04 PM11/1/11
to yipi...@googlegroups.com
Steve,

Could you send over the entire payload of the error you get when using jsonp?

Steve

unread,
Nov 2, 2011, 8:33:00 PM11/2/11
to Yipit API
{"meta": {"total_count": null, "code": 200, "next": "http://
api.yipit.com/v1/tags/?
callback=alertResponse&limit=20&key=btwVtKERaXYCrbSD&_=1320279978598&offset=20",
"previous": null}, "response": {"tags": [{"url": "", "name":
"Restaurants", "slug": "restaurants"}, {"url": "", "name": "Bar &
Club", "slug": "bar-club"}, {"url": "", "name": "Massage", "slug":
"massage"}, {"url": "", "name": "Facial", "slug": "facial"}, {"url":
"", "name": "Manicure & Pedicure", "slug": "manicure-pedicure"},
{"url": "", "name": "Tanning", "slug": "tanning"}, {"url": "", "name":
"Hair Salon", "slug": "hair-salon"}, {"url": "", "name": "Hair
Removal", "slug": "hair-removal"}, {"url": "", "name": "Spa", "slug":
"spa"}, {"url": "", "name": "Teeth Whitening", "slug": "teeth-
whitening"}, {"url": "", "name": "Eye & Vision", "slug": "eye-
vision"}, {"url": "", "name": "Makeup", "slug": "makeup"}, {"url": "",
"name": "Pilates", "slug": "pilates"}, {"url": "", "name": "Yoga",
"slug": "yoga"}, {"url": "", "name": "Gym", "slug": "gym"}, {"url":
"", "name": "Boot Camp", "slug": "boot-camp"}, {"url": "", "name":
"Men's Clothing", "slug": "mens-clothing"}, {"url": "", "name":
"Women's Clothing", "slug": "womens-clothing"}, {"url": "", "name":
"Food & Grocery", "slug": "food-grocery"}, {"url": "", "name":
"Treats", "slug": "treats"}]}}

That is the return value I am getting, along with the invalid label
error

Zach Smith

unread,
Nov 4, 2011, 12:47:33 PM11/4/11
to Yipit API
So invalid label is an exception getting raise by jQuery?

Can you send over your JavaScript?

Thanks

On Nov 2, 8:33 pm, Steve <steven.cira...@gmail.com> wrote:
> {"meta": {"total_count": null, "code": 200, "next": "http://
> api.yipit.com/v1/tags/?
> callback=alertResponse&limit=20&key=btwVtKERaXYCrbSD&_=1320279978598&offset =20",

Steve

unread,
Nov 4, 2011, 2:44:15 PM11/4/11
to Yipit API
sure, I am using jQuery 1.6(now 1.7) have tried this:

function getTagList(){
$.getJSON('http://api.yipit.com/v1/tags/?
key=btwVtKERaXYCrbSD&callback=?', function() {
alert("sent");
success(function(data) { alert(data); })
})

}

and I have also tried this:

var turl = "http://api.yipit.com/v1/tags/?key=btwVtKERaXYCrbSD";
$.ajax({
url: turl,
type: 'GET',
dataType: 'jsonp',
jsonp: false,
success: function(data) {
alert(data);
}
});
}
Still getting the invalid label error.

Chris C

unread,
Nov 4, 2011, 3:18:38 PM11/4/11
to Yipit API
Let me see if I can help.

You're requesting the tags right? It seems your getting a list of all
the tags from the query. Are you having trouble accessing the actual
tags in the json?

Steve

unread,
Nov 4, 2011, 3:32:03 PM11/4/11
to Yipit API
Yes, just getting started and figured I would try a simple call to get
started but I am getting an invalid label error. I am attempting to
put the entire return string into the alert function just as a test
but am getting an invalid label error. I am not trying to parse the
result yet, could that be my error? When I change the datatype to
plain json I get a 200 response but it is empty. Any insight would be
much appreciated.

Chris C

unread,
Nov 4, 2011, 3:45:28 PM11/4/11
to Yipit API
Alright, I hope I can give you the right answer.

So alerting the whole string would probably give your like an [Object
object] type thing. If you have firebug, console.log(data) to see the
results you get.

Since your using jquery, you need to use $.each() function -
http://api.jquery.com/jQuery.each/

Also, the tags are stored in data.response.tags. So this is probably
how you'll write it:

$.each(data.response.tags, function(i,tag))
{
var name = tag.name;
var slug= tag.slug;
});

Don't know if that's right but you gotta write it something like that.
I do know you have to go into data->response->tags though. I've worked
with yipit's api like a billion times and that always been the problem
I've ran into.

Steve

unread,
Nov 4, 2011, 4:23:15 PM11/4/11
to Yipit API
Thanks for your help but now i am more confused. i understand i need
to iterate through the result to get specific values but shouldn't I
be able to alert(data) to see the entire result? That is the step that
is throwing the invalid label error. I get the same error when i try
to console.log(data) in the success function. If this step is throwing
an error would iterating through the return value solve the problem?

I am trying to use alert(data) so i can ensure I am receiving a valid
response and then will worry about parsing the response from their
however i cannot get a valid response. Should I be able to see the
received value with the alert function or is that incorrect? Thanks
for your help.

On Nov 4, 12:45 pm, Chris C <chr...@alphanetcs.com> wrote:
> Alright, I hope I can give you the right answer.
>
> So alerting the whole string would probably give your like an [Object
> object] type thing. If you have firebug, console.log(data) to see the
> results you get.
>
> Since your using jquery, you need to use $.each() function -http://api.jquery.com/jQuery.each/

Zach Smith

unread,
Nov 4, 2011, 4:29:34 PM11/4/11
to yipi...@googlegroups.com
Steve,

They are some bugs with our JSONP implementation at the moment. I'll work on getting these fixed and pushed out as soon as we can.

I apologize for the inconvenience and any headaches this may have caused you.

I'll be sure to reach out to the list when these issues are resolved.

Zach


--
Zach Smith
Technical Product Manager | yipit


Steve

unread,
Nov 4, 2011, 4:33:06 PM11/4/11
to Yipit API
Thanks Zach, still learning this stuff so I definitely have a tough
time troubleshooting. I will wait till I get word from you on the bug
fixes.

Ben Plesser

unread,
Nov 30, 2011, 1:05:07 PM11/30/11
to Yipit API
Hi Steve,

I don't know whether you were able to figure this issue out but I have
a thought as to how to resolve it.

You seem to be receiving a json object as the payload, rather than the
intended jsonp object. To receive the correct response type, you can
do one of the following two things:

1) Add the query parameter, "format=json", to the url (i.e.
http://api.yipit.com/v1/tags/?key=btwVtKERaXYCrbSD&format=json).

2) Change your HTTP Accept Header to "application/json".

Either of these fixes should return the correct jsonp object. I
suspect that your client was sending the incorrect Accept Header
("text/html").

Sorry for the delay. I hope that helps.

Ben

Reply all
Reply to author
Forward
0 new messages