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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:32:32+00:00 2026-05-26T05:32:32+00:00

i’m in the process of modifying this excellent javascript library for autocomplete-ing html input

  • 0

i’m in the process of modifying this excellent javascript library for autocomplete-ing html input see here… as i need to pass some extraparameters to the Ajax call. Actually i’m looking for something non destructive so that it can manage a default behaviour of this lib, that will also be able to handle “no extraparameters”.

so i think i will have a call like

myExtra = {b : 'b', c: 'c'} 
// or maybe a thing like myExtra = "{b : 'b', c: 'c'}" 
myAutoComplete = new Autocomplete('query', { serviceUrl:'autoComplete.rails'}, myExtra);

with a null test for myExtra that does nothing if null or ‘add’ the content of myExtra to the Ajax request, so that this part:

  new Ajax.Request(this.serviceUrl, {
    parameters: { query: this.currentValue , },
    onComplete: this.processResponse.bind(this),
    method: 'get'
  });

become something like when myExtra is not null or empty string:

  new Ajax.Request(this.serviceUrl, {
    parameters: { query: this.currentValue , b: 'b', c: 'c'},
    onComplete: this.processResponse.bind(this),
    method: 'get'
  });

as i’m brand new to web developpment, my trouble is that i do not know how to add curly bracktetted content {} to another one (and i’m not sure that i even understand well what are these {}…)

i think i want to do this king of things that Python accept, but i just do not know how Javascript can do that,

 >>> class A:
def __init__(self, data):
    self.data = data
 >>> a = A("my data")
 >>> dir(a)
 ['__doc__', '__init__', '__module__', 'data']
 >>> myExtra = "b='b';c='c'"
 >>> for x in myExtra.split(";"):
    var, value = x.split('=')
        setattr(a, var, value)

 >>> dir(a)
 ['__doc__', '__init__', '__module__', 'b', 'c', 'data']
 >>> print a.data, a.b, a.c
 my data 'b' 'c'

so please, if you have any pointers for understanding this, Thank you in advance.

  • 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-26T05:32:33+00:00Added an answer on May 26, 2026 at 5:32 am

    As @Matt already said in his comment, this pair of curly bracket is an object literal and creates an object. It is the same as

    var myExtra = new Object();
    myExtra.b = 'b';
    myExtra.c = 'c';
    

    but much more concise and the preferred way of creating an object.

    I think what you want to do is copying properties from one object to another. You can do this by iterating over all properties of one object, using a for...in [MDN] loop:

    var a = {query: this.currentValue};
    var b = {b : 'b', c: 'c'};
    
    for(var prop in b) {
        if(b.hasOwnProperty(prop) { // safe guard (might not be necessary)
            a[prop] = b[prop];
        }
    }
    

    To learn more about objects have a look at the MDN JavaScript Guide – Working with Objects.

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

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
this is what i have right now Drawing an RSS feed into the php,

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.