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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:00:00+00:00 2026-06-15T21:00:00+00:00

The problem My jQuery template does not seem to be reading and/or building the

  • 0

The problem

My jQuery template does not seem to be reading and/or building the html from the json that is passed to it. I cannot see, at which stage, the problem occurs.

The html

<li class="span3">
    <div class="thumbnail">
        <img src="<%= rsProd("Image") %>" alt="<%= rsProd("Description") %>" width="120" height="80" />
        <div class="caption">
            Order: <input type="text" style="width:100px" id="txtOrder-<%= rsProd("ImageID") %>-<%= rsProd("ImageOrder") %>" name="txtOrder-<%= rsProd("ImageID") %>-<%= rsProd("ImageOrder") %>" value="<%= rsProd("ImageOrder") %>" class="listorder" maxlength="5" />
            <br />
            <% if rsProd("ImageID") = rs("MainImage") then %>
            <button id="btnSetMain-<%= rsProd("ImageID") %>-<%= rsProd("ImageOrder") %>" name="btnSetMain-<%= rsProd("ImageID") %>-<%= rsProd("ImageOrder") %>" class="btn btn-primary btn-inverse btnSetMain" disabled="disabled">Current</button>
            <% else %>
            <button id="btnSetMain-<%= rsProd("ImageID") %>-<%= rsProd("ImageOrder") %>" name="btnSetMain-<%= rsProd("ImageID") %>-<%= rsProd("ImageOrder") %>" class="btn btn-primary btnSetMain">Set main</button>
            <% end if %>
            <button id="btnOrderRemove-<%= rsProd("ImageID") %>-<%= rsProd("ImageOrder") %>" name="btnOrderRemove-<%= rsProd("ImageID") %>-<%= rsProd("ImageOrder") %>" class="btn btn-warning btnOrderRemove">Remove</button>
        </div>  
    </div>
</li>

The jQuery template

<script id="imagesTemplate" type="text/x-jquery-tmpl">
  <li class="span3">
    <div class="thumbnail">
        <img src="${image}" alt="${description}" width="120" height="80" />
        <div class="caption">
            Order: <input type="text" style="width:50px" id="txtOrder-${imageid}-${imageorder}" name="txtOrder-${imageid}-${imageorder}" value="${imageorder}" class="listorder" />
            <button id="btnSetMain-${imageid}-${imageorder}" name="btnSetMain-${imageid}-${imageorder}" class="btn btn-primary btnSetMain ${extraclass}" ${disabled}>${text}</button>
            <button id="btnOrderRemove-${imageid}-${imageorder}" name="btnOrderRemove-${imageid}-${imageorder}" class="btn btn-warning btnOrderRemove">Remove</button>
        </div>
    </div>
  </li>
</script>

The returned JSON

{"result": 
    {"0": {
          "imageurl": "\u002Fimages\u002Fmainimages\u002Fimage-01.jpg",
          "description": "",
          "imageid": 25,
          "imageorder": 1,
          "extracss": "",
          "Disabled": "",
          "text": "Set Main"
          },
     "1": {"imageurl": "\u002Fimages\u002Fmainimages\u002Fimage-02.jpg","description": "test","imageid": 17,"imageorder": 2,"extracss": "","Disabled": "","text": "Set Main"},
     "2": {"imageurl": "\u002Fimages\u002Fthumbnails\u002Fimage-03.jpg","description": "test","imageid": 15,"imageorder": 4,"extracss": "","Disabled": "","text": "Set Main"},
     "3": {"imageurl": "\u002Fimages\u002Fmainimages\u002Fimage-04.jpg","description": "","imageid": 24,"imageorder": 5,"extracss": "","Disabled": "","text": "Set Main"},
     "4": {"imageurl": "\u002Fimages\u002Fmainimages\u002Fimage-05.jpg","description": "test","imageid": 16,"imageorder": 7,"extracss": "","Disabled": "","text": "Set Main"}
    }
}

The jQuery code

The jQuery code that is run when the user clicks a button, this all works apart from the populating of the template

success:function(data, textStatus, jqXHR){
    $('#prodThumbs').empty();
    thumbs = data.items;
    $.template('thumbsTemplate');
    $('#imagesTemplate').tmpl(data.result).appendTo('#prodThumbs');
}

the data.result seems to be correctly producing the right json data from a correct json response, however the applying the data to the template doesn’t seem to work

For completeness, i’ve attached the Classic ASP server side function.

set images = server.createObject("scripting.dictionary")
i = 0
While (NOT rsProd.EOF)

    set image = server.createObject("scripting.dictionary")
    image.Add "imageurl", rsProd("Image").value
    image.Add "description", rsProd("Description").value
    image.Add "imageid", rsProd("ImageID").value
    image.Add "imageorder", rsProd("ImageOrder").value
    if rsProd("ImageID").value = request.Form("main") then
        image.Add "extracss", "btn-inverse"
        image.Add "disabled", "disabled=disabled"
        image.Add "text", "Current"
    else
        image.Add "extracss", ""
        image.Add "Disabled", ""
        image.Add "text", "Set Main"
    end if

    images.Add i, image

    i = i + 1

rsProd.MoveNext()
Wend
result = (new JSON)("result", images, false)

rsProd.Close()
response.Write result
response.End

i’m using nested dictionaries to build an object that I can (and seems to) return correctly as JSON (using Michal Gabrukiewicz’s ASP JSON utility class.)

I feel like i’m missing something really simple, however i’ve banged my head against the desk so much now, i can’t see it.

The outcome

the html starts off as

<ul id="images">
    <li><img src="/image/initial.jpg" alt="test" id="initial" /></li>
</ul>

the function

$('#images').empty();

leaves me with

<ul id="images">

</ul>

the function

thumbs = data.images;

correctly stores the json, but then function

$('#imagesTemplate').tmpl(thumbs).appendTo('#images');

still leaves me with

<ul id="images">

</ul>
  • 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-15T21:00:02+00:00Added an answer on June 15, 2026 at 9:00 pm

    Well I managed to fix this by using the following code, after nested dictionaries didn’t appear to work

    arraySize = 0
    arraySize = (rsProd.RecordCount - 1)
    dim imageArrays 
    redim imageArrays(arraySize)
    set images = server.createObject("scripting.dictionary")
    i = 0
    While (NOT rsProd.EOF)
    
        set image = server.createObject("scripting.dictionary")
        image.Add "imageurl", rsProd("Image").value
        image.Add "description", rsProd("Description").value
        image.Add "imageid", rsProd("ImageID").value
        image.Add "imageorder", rsProd("ImageOrder").value
        if rsProd("ImageID").value = request.Form("main") then
            image.Add "extracss", "btn-inverse"
            image.Add "disabled", "disabled=disabled"
            image.Add "text", "Current"
        else
            image.Add "extracss", ""
            image.Add "disabled", ""
            image.Add "text", "Set Main"
        end if
        set imageArrays(i) = image 
        i = i + 1
    
    rsProd.MoveNext()
    Wend
    result = (new JSON)("result", imageArrays, false)
    
    rsProd.Close()
    response.Write result
    response.End
    

    I managed to assign each image dictionary to an index in an array, and then converted that array to JSON. I had already previously tried this method before but failed at this step

    set imageArrays(i) = image 
    

    principally because i wasn’t using the ‘set’ keyword

    so some credit to @SearchAndResQ for telling me to use array of dictionaries in the comments which i had previously tried, but this made me look back at it again.

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

Sidebar

Related Questions

I have a problem with Jquery function getJSON, the action url does not trigger
I have jQuery based template from themeforest and i building on this ASP.NET Web
My site uses jQuery 1.4.2. The problem is .replaceWith() does not work in IE6
Hey I'm having a problem with inserting an ICanHaz.js template into a jquery mobile
I have a problem with jQuery, I want to change a DIV (not the
I am having a problem with the new anonymous template engine. It cannot use
I am developing a WordPress page that uses a jquery.slideto.js navigation system and html
I have a problem of jQuery's live() function not working with click, mousedown but
I have a JSON data object and a text/html javascript template written using the
I have a C# application that generates an html document from transforming an xml

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.