tags:

views:

115

answers:

4

I am using HTML and trying to get a JSON response from a URL.

I ran in to cross domain issues.

I then tried using a callback function in order to avoid this problem.

When I do so, and the control passes to the function. I see a "Invalid Label" error in firebug and it shows the JSON response that i get back.

When i did some reading i found a few articles which said the invalid label error could occur because the first word of the JSON response is thought of as a Javascript label and it should be wrapped as a string.

However it did not work because firebug throws the error before even it hits the first line of the function. I also tried debugging in chrome and I get the same result.

Any input would be greatly appreciated.

A: 

Found something that might help for you here

Quote from there:

The problem occurs because eval is interpreting the first item in the JSON string as a JavaScript Label. The solution is to wrap the JSON string in parenthesis.

o.k.w
A: 

See this link

I'd suggest using jQuery's .json method to retrieve json, because it hides this implementation.

Jim Schubert
sorry, okw beat me to it
Jim Schubert
A: 

@ o.K.W

I tried doing that. It was one of the first things i did.

But I get hit by this error, the moment the call back function is called.

So any code that goes inside the callback function does not get executed.

A: 

Thanks for the replies.

I tried the changes and still was facing the same issue. THe solution of wrapping the json string in parenthesis does not solve the problem because this issue is faced even before the code hits that portion.

The problem was that the API was not call back enabled. ( Grrr :() I know! But that was the issue. once the API callback was enabled, the code worked like a charm.