/    Sign up×
Community /Pin to ProfileBookmark

Creating dynamic links – newbie

Hi all –

I’ll admit to being a newbie with JQuery, XML and Ajax.

I’m trying to create a page which pulls dynamic links from an XML file.

Here is the page: [url]http://www.jessweiss.com/testing/mytro/greendeals/index3.html[/url]

Here is the link to the xml file: [url]www.jessweiss.com/testing/mytro/greendeals/dailydeals.xml[/url]

I can get the url to pull as text, but I cannot make it into a link, no matter what I seem to try. I’m sure it’s a syntax error – but I just don’t know enough to know what it is. ?

I’m also going to need to pull a URL for an image, and I am guessing that the process is similar.

Any help would be super greatly appreciated. TIA!

TIA!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@astupidnameMay 24.2011 — You are just forgetting to wrap the url text into an anchor elements href attribute in order to turn it into a link. As well as create an img tag and put the image text in it's src.

Also, for code readability and manageability, try not to create such long strings, break it up into individual parts more so like below, though even these are kinda long yet.

Try this for your "xmlParser" function:

function xmlParser(xml) {
$('#load').fadeOut();
$(xml).find("deal").each(function () {
var image = '<img src="'+ $(this).find("image").text() +'" alt="" width="208">',
title = '<p class="title"><a href="'+ $(this).find("url").text() +'">'+ $(this).find("title").text() +'</a></p>',
description = '<div class="description">'+ $(this).find("description").text() +'</div>',
price = '<div class="price">Our Price '+ $(this).find("price").text() +'</div>',
retailPrice = '<div class="retail_price">Suggested Retail Price '+ $(this).find("retail_price").text() +'</div>';
$(".main").append('<div class="deal">'+ image + title + description + price + retailPrice +'</div>');
$(".deal").fadeIn(1000);
});
}
Copy linkTweet thisAlerts:
@weissjlauthorMay 24.2011 — Thank you, thank you, thank you! When I see it that way, it seems so simple. I really appreciate it! ?
×

Success!

Help @weissjl spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...