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 7045905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:35:13+00:00 2026-05-28T02:35:13+00:00

I am trying to access a result in a dictionary held in a Python

  • 0

I am trying to access a result in a dictionary held in a Python global variable within JavaScript.

var selected = jQuery('.target option:selected').text()
var list = "${c.persons_by_permission["+selected+"]}"

If I directly access the dictionary without the using the variable:

var list = "${c.persons_by_permission['stringID']}"

Then the code works.

However, when I am trying to use the variable to access the dictionary I get a syntax error (I believe its because of the curly braces).

I have tried escaping the braces with:

var list = "${{c.persons_by_permission["+selected+"]}}"

But it gives more syntax exceptions.

Any ideas?

EDIT:

This is not an issue of whether I can use Python and javascript together, it is more of a question of escaping the curly brackets

I am using pylons, so if I try:

alert("${c.persons_by_permission['Documents']}")

I will get the results I need. The issue is that I cannot find a way of passing a variable into the javascript in place of ‘Documents’

  • 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-05-28T02:35:14+00:00Added an answer on May 28, 2026 at 2:35 am

    I’m making a few (reasonable) assumptions here…

    • Your Python is running on your webserver
    • Your JavaScript is running on your client

    As far as the Python is concerned it is outputting text. It doesn’t care that the browser might interpret it as HTML, JavaScript or whatever. It just generates some text and then sends it to the browser.

    With HTTP you get to make a request and have a response. You cannot stop a response half way through to get data back from the client.

    You cannot pass data from client side JS back to the Python process that generated the JS. That process will have finished running.

    You can either:

    • Send all the data to the client in the first place (and then select the bits you want in JS instead of in Python)
    • Have the JavaScript make a new HTTP request to the server and process the response in JS (this is known as Ajax and there are no shortage of tutorials out there for this)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to access the Facebook API Admin.getMetrics method via jQuery. I'm correctly composing
I am trying to access the Cache in the Application_Start method of Global.asax. I
I'm trying to do some filing with Silverlight and have access the result from
I have Chrome 7.0 and am trying to access fields of a global object.
I'm trying to access data within a JSON object I create using json_decode (based
I'm trying to programmatically access the result of executing the system stored procedure sp_spaceused.
I am trying to access an online XML file and display it's contents within
Im trying to access a web service from a remote computer. I managed to
Im trying to access the Magento customer session in another part of my website.
Im trying to access a Sql CE 2005 database on a windows mobile device

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.