SyntaxError: missing ; before statement - JSON jQuery AJAX

Avatar image for finbarmaginn
finbarmaginn

2

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

I'm trying to pull data from the API to allow me to build my own personal web based cataloguing system. Using JavaScript and jQuery's AJAX method I am able to make a call to the database. The call seems to be able to pull results from the database but I am getting a syntax error instead of being able to parse the data.

In the error console I'm receiving the following:
SyntaxError: missing ; before statement search:1:8

after clicking on the link that is presented on "search:1:8" it brings me to a separate window which contains all the JSON data that I require. I believe my call to the database is correct but here is a sample of my code anyway...

No Caption Provided

Please note that the character variable is Batman

Avatar image for geeksvilleaz
geeksvilleaz

3

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

You are doing a JSONP call, which expects the response to be wrapped in a callback function. Change the format in your request to jsonp, and add `&json_callback=YOUR_FUNCTION`, for example:

`http://www.comicvine.com/api/search?api_key=[MY API KEY]&limit=1&format=jsonp&json_callback=handleCallback`

Then include a function called handleCallback:

function handleCallback(response) {
// do something with your response;
}

Its been awhile, but the jQuery jsonp call may have a built in callback function. Double check their api documentation.