Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8611335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:21:00+00:00 2026-06-12T04:21:00+00:00

The following is triggering a syntax error ( unexpected identifier in Chrome, and missing

  • 0

The following is triggering a syntax error (unexpected identifier in Chrome, and missing ] after element list in Firefox):

infowindow.setContent('<h3>'+locale+' ('+hour+':00): $'+s.total+'</h3><img src="'+fname+'" onclick="open_dialog('+flot_data+');" style="cursor:pointer;" />');

Specifically, the '+flot_data+' in onclick="open_dialog('+flot_data+');". Removing this bit removes the syntax error.

Firebug points (literally) to flot_data which it represents with [object Object] (it points to the O in the second Object. The json was generated by PHP’s json_encode, so I don’t think the json is malformed (also I am elsewhere in this app able to successfully operate on all the parts of this object that I’m trying to use here).

I tried leaving in the onclick and commented out the contents of my open_dialog function to ensure the syntax error isn’t triggered inside it. And, I tried copying the contents of my open_dialog() function directly into the onclick like so:
onclick="$.plot($(\'#graph\'),'+flot_data+');"
(the onclick is encased in '' and uses "", so I had to use escaped single quotes)

I copy/pasted the data being passed to setContent and validated it in a fiddle. Why is the syntax incorrect here but not in the validation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:21:01+00:00Added an answer on June 12, 2026 at 4:21 am

    The problem is that flot_data is not a JSON string; it has apparently already been parsed into a JavaScript object, maybe by the AJAX call that retrieved it. You can’t concatenate an object with a string and expect to see JSON; the language has no idea what its original format was, and can’t convert it back.

    You need to either use the raw JSON string and then parse it inside of open_dialog, or a much better idea would be to avoid the inline handler altogether, and attach the click listener in your script, using jQuery’s .click(function).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble validating my html, my menus are triggering the following error:
Following Script isn't working in CHROME browser, IE is Fine. I've changed opener.document ...
I'm using the following code to watch for changes to a given SELECT element.
I am getting the following PHP Fatal Error Fatal error: Uncaught exception 'Exception' with
I have the following code to show the next element in the dom on
I'm triggering a page reload through javascript, using the following: window.location.reload(true); However, in some
following situation: <body> <div style=position:fixed; width:100%>[place holder for header]</div> <div style=position:relative;width:100%;margin-top:100px>[content]</div> </body> I need
Following code produces a nested array as a result for keys containing three items:
Following code takes like 2500 milliseconds on an i7-*3.4 GHz windows-7 64-bit computer to
Following are the simple statements in the irb shell. What does nil in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.