views:

73

answers:

1

I have the part of the jquery code

 success: function(results) {
        if (results.d.Product.length > 1) {
            var html = '<h3>' + results.d.Product+ '<h3>'
                    + '<div>' + results.d.ProductDescription + '</div>'
                    + '**<a href="#">' + results.d.Url + '</a>';**
            $(test).html(html);
        }

I need to add a absolute address eg. http://comcast.net

How can I do that.

Thanks, SA

+2  A: 

Your code doesn't escape the values (unless that's done on the server).

It would be better done like this:

$(test)
    .empty()
    .append($('<h3 />').text(results.d.Product))
    .append($('<div />').text(results.d.ProductDescription))
    .append(
        $('<a />')
            .attr('href', "http://yourdomain.tld/" + results.d.Url)
            .text(results.d.Url)
        );

I assume that this is what you're trying to do. Note that you might need to remove the / from the domain name string if the URL from the server already has it.

SLaks