Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8061963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:30:25+00:00 2026-06-05T10:30:25+00:00

This may be too much info but here you go… User inputs a url

  • 0

This may be too much info but here you go… User inputs a url and the url is sent to the backend via ajax to confirm it exists. If it does, it returns the url and the contentType (text/html, image/jpeg…ect). Code below is the ajax success callback.

var template = 
"<span class='urlFile'>"+data.contentType+'</span>'+
"<span class='urlPath' title="+data.url+'>'+data.url+'</span>';

$(template).prependTo(fieldWrapper);

The problem is the resulting html renders partially out of order. Below is the output complements of Firebug (Chrome). Note the data.url (http://api.jquery.com/appendto/) is not wrapped in the span.urlPath.

<span class="urlFile">html</span>
<span class="urlPath" title="http://api.jquery.com/appendto"></span>
.appendTo()

Furthermore, when I add in an alert(template) I get:

<span class='urlFile'>html</span>
<span class='urlPath' title=http://api.jquery.com/prependto/>http://api.jquery.com/prependto/</span>

…which is correct. I believe the problem has something to do with the browser rendering the trailing /; however, I am not sure how to fix it other than removing the slash.

FYI: Removing the trailing slash seems to fix the problem, ie:

var url = data.url.replace(/\/$/,'');

… but is it really needed? Sounds like it is a bad idea based on this:

Is it always safe to remove a trailing slash from a URL?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:30:28+00:00Added an answer on June 5, 2026 at 10:30 am

    You are right about the trailing slash. The browser thinks that you are closing the second span element. To fix this put the title attribute in quotes like this:

    var template = 
    "<span class='urlFile'>"+data.contentType+'</span>'+
    "<span class='urlPath' title='"+data.url+"'>"+data.url+'</span>';
    
    $(template).prependTo(fieldWrapper);​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be too much trouble, but I have an object I'm trying to
I may be thinking too much on this, but let's say I have a
may be too simple groovy question but....please help i have a list like this:
I think I may of zoomed in too much with my XStream work, but
This may be a religious argument, but it has been debated ad-nauseum here at
This problem may be a bug. i have spent too much time trying to
This may be too obscure a question, but perhaps someone can spot what I'm
This question may sound too silly, however , I don't find concrete answer any
Well, I'm learning Scala so this question may be too basic for most people.
This may be a dumb question, but I can't seem to find an answer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.