0

Update: I tried a version of the script without the "beforeContentUpdate" part, and this script returns the following JSON

{"COLUMNS":["TNAME","TBRIEF","GAMEID","TITLEID","RDATE","GNAME","PABBR","PNAME","RSCORE","RNAME"],
"DATA":[["Dark Void","Ancient gods known as 'The Watchers,' once banished from our world by superhuman Adepts, have returned with a vengeance.",254,54,"January, 19 2010 00:00:00","Action & Adventure","X360","Xbox 360",3.3,"14 Anos"]]}

Using the script that includes "beforeContentUpdate," however, returns nothing. I used Firebug to see the contents of the div generated by the tooltip, and it's blank!

Hello, I'm wondering if anyone can help me with a syntax error in line 14 of this code: The debugger says missing ) in parenthetical on var json = eval('(' + content + ')');

// Tooltips for index.cfm 
$(document).ready(function() 
{
    $('#catalog a[href]').each(function()
    {
        $(this).qtip( {
            content: {
            url: 'components/viewgames.cfc?method=fGameDetails',
            data: { gameID: $(this).attr('href').match(/gameID=([0-9]+)$/)[1] },
            method: 'get'
        },
        api: {
            beforeContentUpdate: function(content) {
            var json = eval('(' + content + ')');
            content = $('<div />').append(
            $('<h1 />', {
                html: json.TNAME
                }));
                return content;
            }
        },
        });
    });
});

4 Answers 4

2

You forgetting a

+

Should be:

var json = eval('(' + content + ')');
Sign up to request clarification or add additional context in comments.

7 Comments

I added the "+", but now I get another error on the same line that says "missing ) in parenthetical" -- any ideas?
quote: The missing parenthetical typically indicates that something in the JSON is wrong. It could be an extra character before/after the string. Use Firebug to examine what you are getting back, and make sure it is clear of any extra characters.
@Mel, you have an extra , after the api : {..} between that and the next }.
whatever content is, it must be valid js, this tool might be helpful: http://www.jsonlint.com/
|
1

the best for this is www.jslint.com

i'd copied and paste your code and show me this:

Problem at line 21 character 10: Extra comma.

},

1 Comment

Taking out the comma makes not different unfortunately! IT says "problem at line 14: eval is evil" what sort of error is that?
1

Make sure you JSON has no extra characters, the JSON must be valid. Check how the content returns with a plain alert so nothing will change the string.

Also, consider using parseJSON from jQuery instead of eval. Quote:

var obj = jQuery.parseJSON('{"name":"John"}');
alert( obj.name === "John" );

Comments

0

This turned out to be another case where the ColdFusion debugger, when request debugging output is turned on, causes an ajax error. This is one big "gotcha" we need to remember when working with ColdFusion with debugging enabled. It breaks down ajax.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.