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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:32:05+00:00 2026-06-09T06:32:05+00:00

I am new to Javascript and Jquery. I am using Jquery $.ajax for sending

  • 0

I am new to Javascript and Jquery.

I am using Jquery $.ajax for sending get request, dealing with returned Json String and use .html() to display contents in <div id="myTabs"></div> in my html. You can see from my code below, I am using a String variable to make a HTML list. Am I doing this in a good practice? I feel this way is not very agile, Is there any better way of doing this?

Thanks!

function updateRelated(str)
{
    $.ajax(
        {
            url:ServerUrl+api_subject,
            type:'GET',
            success:function(json)
            {
                // alert(json);
                var obj = jQuery.parseJSON(json);

                var toDisplay="";
                var tableDisplay="<ul>";
                for(var i=0;i<obj.subject_list.length;i++)
                {
                    tableDisplay=tableDisplay+'<li><a href="subject.htm?subjectid='+obj.subject_list[i].id+'">'+obj.subject_list[i].title+'</li>';
                    //    toDisplay=toDisplay+"<br>preferred_synonym:"+obj.relatedCocepts[i].preferred_synonym+",Type: "+obj.relatedCocepts[i].type+",score: "+obj.relatedCocepts[i].score;
                }
                tableDisplay=tableDisplay+"</ul>"
                $("#myTabs").html(tableDisplay);
            }
        }
        )
 }
  • 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-09T06:32:07+00:00Added an answer on June 9, 2026 at 6:32 am

    basically i’m reading your question to be really asking whether or not you should be writing a string of markup and outputting it into the dom, with variables concatted into it.

    Its ok to do for smaller stuff, but if you’re writing a lot of views with javascript, you’ll want a tool for putting together view partials.

    There are tools out there that do this:

    • http://mustache.github.com/
    • https://github.com/adammark/Markup.js
    • http://api.jquery.com/category/plugins/templates/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using JQuery's ajax() or get() methods we can make an async call to the
I currently have the following JavaScript/jQuery script that gets an external html page using
I am new to JavaScript and jQuery, but have used HTML and CSS before.
I am using jQuery.ajax(...) to retrieve JSON data from an ASP.NET MVC service. When
I'm new to javascript/jquery and I've done some poking around the web, but I
I'm very new to Javascript (and jQuery). My JSFiddle really shows the issue in
I'm really new to JavaScript and jQuery. My question is this. I have two
I'm new to JQuery/Javascript etc... based on the following article: How to make an
I'm pretty new to Javascript, Rails and JQuery all working together. I'm going through
im new to jquery and javascript.. Here is the code, this is a sample,

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.