here is the code:
<script type="text/javascript">
var ajax_data =
'<ul id="b-cmu-rgt-list-videos"><li><a href="{video.url}" '+
'title="{video.title.strip}"><img src="{video.image}" '+
'alt="{video.title.strip}" /><span>{video.title}</span></a></li></ul>';
var my_img = $(ajax_data).find('img');
</script>`
ajax_data is data from a JS template engine where I need to get some part of it. The problem is that jQuery does a GET on the
img src={video.image}: GET /test/%7Bvideo.image%7D HTTP/1.1
(on Firefox Live HTTP headers).
This GET generates a 404 from the server.
Any clues on how to solve this?
Thanks a lot 🙂
When you create a jquery object from html, it’s immediately evaluated (because the document fragment is created), so this:
Immediately causes a fetch of the image. The way I see it you had 3 quick options (and probably others, but hard to say without more context to your question):
{video.image}before creating the jQuery object.src="{video.image}", just find the<img>via the selector you already have and set thesrcattribute later, like this:$(ajax_data).find('img').attr('src','myImage.jpg');