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

  • Home
  • SEARCH
  • 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 8979625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:53:25+00:00 2026-06-15T19:53:25+00:00

I am creating a commercial API for the first time for responsive webpages/web applications

  • 0

I am creating a commercial API for the first time for responsive webpages/web applications (mobile devices).

I am new and, sadly, working alone as well as new to Javascript (long complicated story).

I was just wondering if someone from the industry could offer their professional opinion on the following format of a “get” call:

var getSample = function(params) {
    //Returns Object
    return $.ajax({ 
        url: URL + 'downloadQuadrat.php',
        type: 'GET',
        data: { 'projectID': params.pid, 'quadratID': params.qid },
        dataType: dataType
    });
}

Function call:

var printList = function(lid,options,get) {
    var list = $("ul#"+lid);
    var promise = get(options);

    promise.promise().then(
        function(response) {
            var items = response;
            list.empty();

            $.each(items, function(item,details) {
                var ul = $('<ul/>');
                ul.attr('id', lid+'_'+details.ID);
                var li = $('<li/>')
                .text(details.ID)
                .appendTo(list);
                ul.appendTo(list);

                $.each(details,function(key,value) {
                    var li = $('<li/>')
                    .text(key+': '+value)
                    .appendTo(ul);
                });
            });
        }
    );
}

Any input or guidance will be hugely appreciated.

  • 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-15T19:53:26+00:00Added an answer on June 15, 2026 at 7:53 pm

    I’m not a professional from the industry, per se, but there’s a few things that I think would improve your code:

    • Format it according to common conventions. It’s hard to see what your code is doing without proper indentation.
    • Just use $("#"+lid) instead of $("ul#"+lid). The ul at the beginning does not add any disambiguation because id attributes must be unique, and it just make it take longer to parse.
    • Ditch localstorage in this case. It’s not supported on all browsers, and as far as I can tell, you don’t need it here. Just directly use the data returned from the response.

    Here is how I would change your code:

    var printList = function(lid, options, get) {
        var promise = get(options);
        var list = $("#" + lid);
    
        promise.success(function(response) {
            var data = response;
            list.empty();
            $.each(data, function(item, details) {
                var ul = $('<ul/>').attr('id', lid + '_' + details.ID);
                var li = $('<li/>').text(details.ID).appendTo(list);
                ul.appendTo(list);
                $.each(details, function(key, value) {
                    var li = $('<li/>').text(key + ': ' + value).appendTo(ul);
                });
            });
        });
    }
    

    EDIT: The edited version of your code looks fine to me, except for the minor ul# thing.

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

Sidebar

Related Questions

I am creating a small commercial web project running Apache/WSGI/Django/MySQL. I have a development
Assume for a moment that you are creating a commercial product for SharePoint. This
What are some tools (commercial or OSS) that provide a GUI-based mechanism for creating
Creating a class at runtime is done as follows: klass = Class.new superclass, &block
I am using a module that is part of a commercial software API. The
I am interested in creating closed source applications for my Nokia N900 using Qt
I am creating a small commercial website where I want only the content to
I've very new at WCF, and I'm creating a prototype application to learn, which
creating a small web application to be deployed on Heroku, where we would like
Are there any disadvantage when creating a commercial software in a Visual Studio Ultimate

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.