jQuery template not using JSON passed from Classic ASP

prariette

New Member
The problemMy 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.You will have to forgive me at this stage as I do not have the code to hand, so although close, some parts are quite psuedoThe html\[code\]<ul id="images"> <li><img src="http://stackoverflow.com/image/initial.jpg" alt="test" id="initial" /></li></ul>\[/code\]The jQuery template\[code\]<script id="imagesTemplate" type="text/x-jquery-tmpl"> <li><img id="image${id}" src="http://stackoverflow.com/questions/13817148/${imageurl}" alt="${description}" /></li></script>\[/code\]The returned JSON (as seen from firebug)actual json will be provided when i can get to my code\[code\]+ images +0 id:21 imageurl:'/images/image21.jpg' description:'a description' +1 id:16 imageurl:'/images/image16.jpg' description:'a description' +2 id:5 imageurl:'/images/image5.jpg' description:'a description' +3 id:9 imageurl:'/images/image9.jpg' description:'a description'\[/code\]The jQuery codeThe jQuery code that is run when the user clicks a button, this all works apart from the populating of the template\[code\]Success:function(data, textStatus, jqXHR){ $('#images').empty(); var thumbs; thumbs = data.images; $('#imagesTemplate').tmpl(thumbs).appendTo('#images');}\[/code\]the thumbs seems to be correctly storing the right json data from a correct json response, however the next line that is supposed to apply the data to the template doesn't seem to run.For completeness, i've attached the basis of the Classic ASP server side function.\[code\]Dim images = Server.Create("scripting.dictionary")-- Some sql that gets images --i = 0while not rsImages.EOF Dim image = Server.Create("scripting.dictionary") image.add "id", rs("id").value image.add "imageurl", rs("imageurl").value image.add "description", rs("description").value images.add i, image i = i + 1nextresult = (new JSON)("images", images, false)response.write result\[/code\]the code above is fairly psuedo, 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 outcomethe html starts off as \[code\]<ul id="images"> <li><img src="http://stackoverflow.com/image/initial.jpg" alt="test" id="initial" /></li></ul>\[/code\]the function\[code\]$('#images').empty();\[/code\]leaves me with\[code\]<ul id="images"></ul>\[/code\]the function\[code\]thumbs = data.images;\[/code\]correctly stores the json, but then function \[code\]$('#imagesTemplate').tmpl(thumbs).appendTo('#images');\[/code\]still leaves me with\[code\]<ul id="images"></ul>\[/code\]
 
Back
Top