views:

36

answers:

2

I can't get this to work for the life of me. The URL concat messes up. The answer doesn't seem obvious...

function(data){
$('#dataDisplay').prepend("<img src='http://url"+data+"moreurl' />").fadeIn("slow");
});

Firebug throws missing end argument errors.

A: 
function xx(data){
$('#dataDisplay').prepend("<img src='http://url"+data+"moreurl' alt='' />").fadeIn("slow");
});

you should name your function as XX for example and i think you must add the ALT attribute

From.ME.to.YOU
Javascript uses anonymous functions. In particular jQuery uses them all over the place in callbacks. The alt tag is nice to have, but it has nothing to do with this issue.
Peter Ajtai
alt is an attribute, not a tag
David Dorward
@David - Thanks, meant attribute..
Peter Ajtai
A: 

Try string replacement using a placeholder instead and stop worrying about escaping.

var img = '<img src="http://url{data}moreurl" />';
img = img.replace("{data}", data);
$('#dataDisplay').prepend(img).fadeIn('slow');
Anurag