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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:32:02+00:00 2026-05-16T22:32:02+00:00

I am using getJson to pull in some info onto the page $(‘#request_song’).autocomplete({ serviceUrl:

  • 0

I am using getJson to pull in some info onto the page

$('#request_song').autocomplete({
  serviceUrl: '<%= ajax_path("trackName") %>',
  minChars:1,
  width: 300,
  delimiter: /(,|;)\s*/,
  deferRequestBy: 0, //miliseconds
  params: { artists: 'Yes' },
onSelect: function(value, data){
    // alert('You selected: ' + value + ', ' + $('#request_artist').val()); 
        $.getJSON('/get_events', function(data) {
                    $(data).each(function(key, value) {
                        console.log(value);
                    });
                });

    },
});

The json will have the name of the event and the city and date

I need to make a have a div that is on the page have the values from the json like

<div id="event_data">

//table info from json 
  • 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-16T22:32:03+00:00Added an answer on May 16, 2026 at 10:32 pm

    I’m guessing your response looks something like this…

    var data = [{
      "event": "Birthday"
      "name": "John Doe",
      "city": "Sunnyvale",
      "date": "04/07/1982"
    },{
      ...
    }]
    

    If you use $('<div />') or $('<div></div>') to create new elements, jQuery will use regex before creating the element which for obvious reasons will slow you down if you’re dealing with large data sets.

    For performance use:

    var div = $(document.createElement('div'));
    
    or keep it simple...
    
    var div = document.createElement('div');
    

    For performance use standard for loop, not $.each, and cache the length:

    var container = $("#event_data");
    
    for(var i = 0, k = data.length; i < k; i++){
      var event = $(document.createElement('div')),
          name = $(document.createElement('span')),
          city = $(document.createElement('span')),
          date = $(document.createElement('span'));
    
      // add id to event wrapper, if undefined generate random ID to avoid conflicts
      event.attr('id', 'event_'+data[i].event || Math.floor(Math.random()*100));
    
      // add each item, if undefined then insert empty text
      name.text(data[i].name || "").appendTo(event);
      city.text(data[i].city || "").appendTo(event);
      date.text(data[i].date || "").appendTo(event);
    
      // append & appendTo do exactly the same thing, markup preference
      container.append(event);
    }
    

    If you use text() the value will be treated as just that, text only, and will not be executed. If you use html() you’ll have XSS issues.

    Hopefully this helps and is what you’re looking for.

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

Sidebar

Related Questions

I have some jQuery code which retrieves content using getJSON(). There are n JSON
I am using jQuery's getJSON method to display content on a mobile website page.
I am trying to pull data using the jQuery getJSON method across domains. I
I am using $.getJSON() to pass some data to the server side (PHP, Codeigniter)
Using getJSON to retrieve some data which I am utf8 encoding on the server-side
I'm currently using $.getJSON to pass an array of ids. It basically constructs a
I'm using jquery $.getJSON to retrieve list of cities. Everything works fine, but I'm
I am attempting to pase a a JSON data using the JQuery getJSON function.
I am using jquery and the getJSON method and I am wondering if there
Using C# .NET 3.5 and WCF, I'm trying to write out some of 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.