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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:00:09+00:00 2026-06-01T08:00:09+00:00

I have a problem when passing data in .getJSON. The reason for this is

  • 0

I have a problem when passing data in .getJSON. The reason for this is because I need to pass variables with same name. So, I have a client in python and I do this with that code :

query_args = { 'name':[var1,var2,var3] }

output = urllib2.urlopen('http://'+servername+':'+port+'/'+action,urllib.urlencode(query_args,doseq=True))

if i try to do that in javasctipt with .getJSON, i try to do

$.getJSON(
    "http://servername::8001/SearchNode",
    {
        name: "name",
        name: "google"
    },
    function(data) {

        $.each(data, function(key, val) {
            console.log(key);
            console.log(val);
        });
    }   
);

When I debug query string I see only one of the variables. Can anyone give me a simple solution to my problem?

Regards

  • 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-01T08:00:11+00:00Added an answer on June 1, 2026 at 8:00 am

    To pass multiple objects within one variable you must use another structure. In your case you want both the string name and google to be sent. By using your method you simply override the value of the variable name.

    There are multiple ways to solve this problem. I must say, that I haven’t used python for a while now (So phytoneers out there, feel free to correct me).

    idea 1:
    Rename parameters in js-code and glue them together in python. Change one key of your 2 parameters, so they don’t override…

    $.getJSON(
        "http://servername::8001/SearchNode",
        {
            name1: "name", 
            name2: "google"
        },
        function(data) {...}
    ) 
    

    …and afterwards rebuild your array…

    query_args = {'name': [name1, name2] }
    

    or alternatively don’t bother with query_args, but rather handle them directly into your urllib.urlencode

    output = urllib2.urlopen('yoururl', urllib.urlencode({'name':[name1, name2]}, True))
    

    idea 2:
    This is probably what you want to do. Put both strings inside an array and sent this as a parameter. At json.org you can have a look at different kinds of datastructures send via ajax.
    In this case, your code would look like this:

    $.getJSON(
        "http://servername::8001/SearchNode",
        {
            name: ["name", "google"]
        },
        function(data) {...}
    ) 
    

    Using this method, you can easily add even more parameters, without adding so many different variables that you need to concat later.
    Since I’m not that familiar with python anymore, I can’t tell you how python will store this (probably a list). But either way, you should be able to handle this as well into the urlencode function. (At least the documentation says, it must be a sequence, which this list certainly is)

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

Sidebar

Related Questions

I have this problem.. I'm receiving data from a client..Using a socket connection. But
I have a problem with passing variables as reference in PHP. I want to
i have problem passing data from one page to another using GET, for example
In my MVC application I have a problem with passing data from view to
I have a problem that I really need solved in any way (changing data
I am passing variables to submit file via AJAX but I have problem when
I have a problem of passing data from one textarea to another textarea on
The Dropdownlist data binding using throw common function. In this have a problem in
problem with passing variables (php, sql, jquery draggable) Hi, this is my problem: updating
I have problem with passing an argument to my simple function in jQuery: When

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.