473,499 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Any advice on why it's not doing a replace?

Paul Johnson
97 New Member
Hi,

I've got a bit of a noggin scratcher here. I've followed the code on the icanhaz website on how to do this, but nothing is working.

What I'm doing is loading in a json file (doesn't contain much, just some bits I want to plug into a web page), using icanhaz to do the replacements and generate the code and inserting it into the page.

From what I can see it's right. No JS errors reported, but then, nothing generated in my template.

Any help on this?

My html looks like this

Expand|Select|Wrap|Line Numbers
  1. <script id="photos_user" type="text/html">
  2. <img src="{{picture_thumbnail}}" alt="{{name}}" />
  3. </script>
  4.  
gallery.js is this

Expand|Select|Wrap|Line Numbers
  1. $(document).ready(function () {
  2.             $.getJSON('json/gallery.json', function(data) { 
  3.                     doPictures(data, '#photos_user');
  4.         });
  5.  
  6.         function doPictures(data, selector) {
  7.         $.each(data.photogallery, function(i,photogallery){  
  8.                 var image_data, photogallery;
  9.                 image_data = {
  10.                         picture_thumbnail: data.photogallery[i].src, 
  11.                         name: data.photogallery[i].name
  12.                     }
  13.                 photos_user = ich.photogallery(image_data);
  14.                 $(selector).append(photographs);
  15.             }); 
  16.         }        
  17.     });
  18.  
and the json file

Expand|Select|Wrap|Line Numbers
  1. {"photogallery": [
  2.         {
  3.         "src" : "images/DSC_0016-2.jpg"    
  4.         "name" : "Thumbnail"
  5.         },
  6.         {
  7.         "src" : "images/DSC_0025-2.jpg"    
  8.         "name" : "Thumbnail"
  9.         },
  10.         {
  11.         "src" : "images/DSC_0230-1.jpg"    
  12.         "name" : "Thumbnail"
  13.         },
  14.         {
  15.         "src" : "images/DSC_0234.jpg"    
  16.         "name" : "Thumbnail"
  17.         },
  18.         {
  19.         "src" : "images/DSC_0321-1.jpg"    
  20.         "name" : "Thumbnail"
  21.         }
  22.     ]
  23. }
  24.  
as I say - nothing out of the ordinary, but no code generated.

Any help here would be appreciated. It's driving me bonkers!
Mar 29 '11 #1
1 1292
Paul Johnson
97 New Member
Making progress, but it dies at the end...

HTML is still the same...
JS is now

Expand|Select|Wrap|Line Numbers
  1. $(document).ready(function () {
  2.             $.getJSON('json/gallery.json', function(data) {
  3.                     doPictures(data, '#photos_user');
  4.         });
  5.  
  6.         function doPictures(data, selector) {
  7.         $.each(data.photogallery, function(i,photogallery){  
  8.                 var image_data, photogallery;
  9.                 image_data = {
  10.                         picture_thumbnail: data.photogallery[i].src, 
  11.                         name: data.photogallery[i].name
  12.                     }
  13. /*alert(image_data.picture_thumbnail); return false; works here/*
  14.                 photos_user = ich.photogallery(image_data);
  15. /*alert fails here*/                
  16. $(selector).append(photos_user);
  17.             }); 
  18.         }        
  19.     });
  20.  
The json file now has a comma between the different fields.

My testing shows that the code is falling over dead at the photos_user= line (as show with the comments).

Full html is this (incase it's me again!)

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3.  
  4. <head>
  5. <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
  6. <title>Slideshow</title>
  7. <link rel="stylesheet" type="text/css" href="css/site-css.css" />
  8. <link rel="stylesheet" href="css/gallery.css" type="text/css" media="screen" />
  9. </head>
  10. <body>
  11. <div id="links-left">
  12. <p>Links on the left</p>
  13. </div>
  14. <div id="links-right">
  15. <p>Links on the right</p>
  16. </div>
  17. <div id="photos">
  18. <script id="photos_user" type="text/html">
  19. <img src="{{picture_thumbnail}}" alt="{{name}}" />
  20. </script>
  21. </div>
  22. <div id="eoe">
  23. <span>Slideshow designed by me</span>
  24. </div>
  25. <script src="js/jquery-1.5.1.min.js" type="text/javascript"></script>
  26. <script src="js/ICanHaz.js" type="text/javascript"></script>
  27. <script src="js/jquery.scrollTo.js" type="text/javascript"></script> 
  28. <script src="js/gallery.js" type="text/javascript"></script>
  29. <script id="photographs" type="text/html">
  30.  
  31. </script>
  32.  
  33. </body>
  34. </html>
  35.  
Mar 29 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2037
by: Nick Ellson | last post by:
I have search and replace task and was hoping to get some advice. I have a large text file of remote access users from Cisco's ACS dumpfile that I need to batch alter 2000 of 3000 users. And...
6
1211
by: strvariant | last post by:
Our company contracted with an outside consultant over a year ago to build a complex database application. The end product was put into production over nine months ago. Since then it has been...
5
2613
by: pembed2003 | last post by:
Hi all, I need to write a function to search and replace part of a char* passed in to the function. I came up with the following: char* search_and_replace(char* source,char search,char*...
1
3071
by: kids_pro | last post by:
Hi there, Is it possible to use RegEx.Replace to replace string like this. string str = "The world heavy weight match"; I want to replace world = w and match = m I can do that with 2 line of...
9
9115
by: Peter Row | last post by:
Hi, I know this has been asked before, but reading the threads it is still not entirely clear. Deciding which .Replace( ) to use when. Typically if I create a string in a loop I always use a...
12
2538
by: Charlie King | last post by:
As I understand it, the use of FIR* to replace heading tags with images in visually enabled CSS browsers is now frowned upon on the basis that some screen readers will *nor* read back text that is...
1
9582
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
13
3082
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those...
4
2353
by: Villanmac | last post by:
Ahhhh, ive missed so many lessons this year that i have to try and teach myself c++ from a book and its so hard. Usually I just read this forums to pick things up but its doing my head in trying to...
0
7131
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7388
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5470
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4600
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
297
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.