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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:27:37+00:00 2026-05-23T18:27:37+00:00

I am trying to figure out how to format JSON in a better way

  • 0

I am trying to figure out how to format JSON in a better way that I am.

I am using form of javascript like this,

<script type="text/javascript">
$(document).ready(function(e) {   
    $.ajax({
        url: 'http://www.domain.ca/classes/brain.php?a=select',
        crossDomain: true,
        type: 'GET',
        dataType: 'json',

        beforeSend: function() {
        },

        success: function(data, textStatus, jqXHR) {
            $('.pageLoaded').html(data.name +' <br />'+ data.email);
        },

        error: function(responseText) {
            alert('Error: '+ responseText.toString());  
        }
    });
});
</script>
<div data-role="content" class="pageLoaded"></div>

But I would like to be able to have a better way to format how the display looks. Perhaps calling a template file?

I can only use HTML + CSS + Javascript… is there any possibilities, or do I have to do what I am doing here?

  • 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-23T18:27:38+00:00Added an answer on May 23, 2026 at 6:27 pm

    For simple html as name + <LINE BREAK> + email, what you are already doing shuold be fine.

    If the HTML gets complex then jQuery.template is your friend.

    For the above situation an example would be:

    1) Add a script tag with the html layout you want to generate:

    <script id="nameTemplate" type="text/x-jquery-tmpl">
       ${name} 
       <br />
       ${email}
    </script>
    

    2) Change your ajax success handler to:

     $( "#nameTemplate" ).tmpl( data).appendTo(".pageLoaded")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out a way to format a date string that sits
I am trying to figure out the most efficient way to format this query.
Trying to figure out how I can do this properly. The print_r looks like
I'm trying to figure out what the best way to handle a JSON object
I am trying to figure out a format spec of to_char() that would give
I'm trying to figure out why String.format() is behaving the way it does. Context:
I'm trying to figure out how could I parse this string using sstream and
I'm trying to figure out how to apply a for-loop to this script and
I am trying to figure out which is the correct format when using the
I am trying to figure out the style string for the Format(Expression as Object,

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.