javascript - Adding the almighty CDATA tag to some PHP-echoed jQuery -



javascript - Adding the almighty CDATA tag to some PHP-echoed jQuery -

attached @ bottom of question code that's beingness echoed out in php-based wordpress plugin. need figure out way create sure javascript wrapped in cdata, becuase it's interfering rss feed generator. help appreciated, i've tried several ways , it's not working correctly. works great plugin except rss feed problem :/ thanks!!

echo '<div id="flickr-images">'; echo '<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>'; echo '<script type="text/javascript">'; echo ' $(document).ready(function() {'; echo '$.getjson("http://api.flickr.com/services/feeds/photos_public.gne?id=' .$userid. '&format=json&jsoncallback=?", function(data) {'; echo ' var target = "#flickr-images";'; echo ' (i = 1 ; <=' .$numpics .'; = + 1) {'; echo ' var pic = data.items[i];'; echo ' var linumber = + 1;'; ?> $(target).append("<li class='hi-flickr-image hif-no-" + linumber + "'><a title='" + pic.title + "' href='" + pic.link + "'><img src='" + pic.media.m + "' /></a></li>"); } }); }); </script> <?php echo '</div>';

either don't understand question, or you're trying do:

echo '<![cdata['; // javascript echoed here echo ']]>';

edit

i assume you're aware code above missing echo statements? single quotes in jquery parts looked throwing off. php didn't execute, did it? anyways, see if works, may have missed few quotes somewhere...

echo '<div id="flickr-images">'; echo '<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>'; echo '<script type="text/javascript">'; echo '<![cdata['; echo ' $(document).ready(function() {'; echo '$.getjson("http://api.flickr.com/services/feeds/photos_public.gne?id=' .$userid. '&format=json&jsoncallback=?", function(data) {'; echo ' var target = "#flickr-images";'; echo ' (i = 1 ; <=' .$numpics .'; = + 1) {'; echo ' var pic = data.items[i];'; echo ' var linumber = + 1;'; ?> echo ' $(target).append("<li class=\'hi-flickr-image hif-no-" + linumber + "\'><a title=\'" + pic.title + "\' href=\'" + pic.link + "\'><img src=\'" + pic.media.m + "\' /></a></li>")'; echo ' }'; echo ' });'; echo ' });'; echo ']]>'; echo '</script>'; echo '</div>';

php javascript wordpress plugins cdata

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -