Trying to integrate the Framey API for video recording has been a bit challenging. While I receive the expected JSON response upon making a request, an error crops up:
Uncaught SyntaxError: Unexpected token :
Here's the snippet of javascript causing the issue:
var url = "http://framey.com/api/videos/ba9bd910-549d-012e-32f4-549a20bdfc52?
api_key=7VNKGLJZLKSASZ0FXN2TVSZQU&signature=41B08D68E0A4AC2DD91107BBD6AD08B8&time_stamp=1304447242";
$("button").click(function() {
$.ajax({
url: url,
dataType: 'json',
crossDomain: true
}).done(function() {
$(".video").html("here it is babyF!");
});
});
The URL provided in the code snippet is just a placeholder from Framey's website and may not be functional. Referencing a related query on StackOverflow, it seems that the issue might lie with the handling of the returned data.
For those facing a similar dilemma - adjusting the server to send back JSON as application/json resolved the problem with jQuery handlers.
Considering I have no control over how Framey sends me data, resolving this discrepancy poses a challenge. Any insights on alternate fixes or solutions are greatly appreciated. Feel free to ask for more information if needed.
=========EDIT============
Upon inspecting the response from Framey triggering the error:
{"success":true,"video":{"name":"6d235a90-7b4b-012f-f97e-12313d297e67","filesize":1335504,"duration":20.48,"state":"uploaded","views":1,"data":{},"flv_url":"http://framey.com/videos/source/6d235a90-7b4b-012f-f97e-12313d297e67.flv","mp4_url":"http://framey.com/videos/source/6d235a90-7b4b-012f-f97e-12313d297e67.mp4","large_thumbnail_url":"http://framey.com/thumbnails/large/6d235a90-7b4b-012f-f97e-12313d297e67.jpg","medium_thumbnail_url":"http://framey.com/thumbnails/medium/6d235a90-7b4b-012f-f97e-12313d297e67.jpg","small_thumbnail_url":"http://framey.com/thumbnails/small/6d235a90-7b4b-012f-f97e-12313d297e67.jpg"}}
The root cause appears to be Framey designating "application/javascript" instead of "application/json." This inconsistency could be contributing to the encountered error.
============ EDIT 2 =================
Included below are the headers associated with the response, gathered from Chrome's console under the "Network" section.
Request URL:http://www.framey.com/api/videos/32a7aaf0-7c3a-012f-37bd-12313b093125?api_key=00000000&signature=624643a3481b2a2c2bdb6c7cc29c506e&time_stamp=1536494436&callback=jQuery17202607689620926976_1336594235235&_=1336594483714
Request Method:GET
Status Code:200 OK
...
(truncated for brevity)
...
Notably, the content-type header indicating "text/javascript" is of particular relevance and likely contributes to the encountered discrepancies.