Search code examples
jqueryajaxcross-domainjsonp

Cross domain Ajax request response "Uncaught SyntaxError: Unexpected token :"


Here is a partial of the JSON i'm trying to access via cross domain ajax request:

{
        "request": "Stream/GetDigest",
        "response": {
            "success": true,
            "content": {
                "0": {
                    "artifact_id": "36",
                    "timestamp": "2013-08-20 11:59:00",
                    "modified": "2013-08-20 11:59:00",
                    "text": "Why did the last one duplicate? I don't think I clicked it twice...",
                    "author_desc": "",
                    "object_type": "artifact",
                    "comments": []
                    },

and so on....

Here is my ajax function:

            loadDigest: function() {
                $.ajax({
                    crossDomain: true,
                    type: "GET",
                    dataType: "jsonp",
                    crossDomain: true,
                    async: true,
                    cache: false,
                    url: 'http://DOMAIN_NAME/Stream/GetDigest?digest_hash=43c4901481f7f1acd825537aa91a7dd36561d30e',
                    success: function(data) {

                        var source      = $('#artifact_list').html(),
                            template    = Handlebars.compile(source),
                            html        = template(data.response);

                            $content_area.html(html);

                    },
                    error: function(error) {
                        $content_area.html('<strong>There was an error: ' + error + '</strong>');
                    },
                    timeout: default_timeout,
                    beforeSend: object_spinner, // calling variable for default loading graphic
                    complete: function() {
                        $content_area.removeClass('is_getting');
                    },
                    jsonp: 'jsonp-callback'
                })

I'm getting a 200 OK status code, however in the console I can't seem to get anything other than "Uncaught SyntaxError: Unexpected token :" on the "GetDigest:1".

I've tried a few different methods i've found on StackOverflow and other places, but can't seem to get this running. Any help would be appreciated.

Thanks!


Solution

  • This is a cross domain json issue.