473,563 Members | 2,856 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 1294
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
2040
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 example user record (they are not all the same size) #----------------------------------------------------------------------------- Name ...
6
1215
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 nothing short of a disaster. There are multiple instances of problematic code that while they work well enough to get most of the job done they...
5
2622
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* replace){ char* result; size_t l = strlen(source), r = strlen(replace), i; int number_of_replaces = 0; for(i = 0; i < l; i++){ if(source == search)
1
3078
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 RegEx.Replace. I wonder is it possible to do it with 1 RegEx.Replace? The example above is simple my real situation is more word to replace I
9
9137
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 StringBuilder. At present I am porting a VB6 webclass app to VB.NET and therefore I am trying to make it as efficent as possible via the new...
12
2549
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 marked up by CSS to be invisible or hidden. So... If I want to replace headings with images (because my client wants to use his specific font...
1
9605
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 and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the...
13
3094
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 sorts of clients. Mine are all small businesses whose sites will never reach those sorts of scales. I deal with businesses whose sites get maybe a...
4
2357
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 work it out, so I thought I would sign up and ask some people who know what they doing. Basically im trying to write a program that reads in the...
0
7665
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.