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

  • SEARCH
  • Home
  • 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 8495695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:38:39+00:00 2026-06-10T23:38:39+00:00

I have a sample url website: http://mysite.com/ var host = window.location.protocol+//+window.location.hostname; $.ajax({ type:POST, data:

  • 0

I have a sample url website: http://mysite.com/

 var host = window.location.protocol+"//"+window.location.hostname;

$.ajax({
   type:"POST",
   data: params,
   url : host+'/forms/get_data.php',
   success:function(data){
       ...othercodeblahblah
   }
});

Why is it that when I try to check my firebug it makes the URL weird.

This is the sample output of firebug:

http://mysite.com/mysite.com/forms/get_data.php

With this url it now gives me:

"NetworkError: 404 Not Found -  http://mysite.com/mysite.com/forms/get_data.php"

Shouldn’t it output like http://mysite.com/forms/get_data.php ?
Why is it giving me a wrong url path?

Your help would be greatly appreciated and rewarded!

Thank!

  • 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-10T23:38:40+00:00Added an answer on June 10, 2026 at 11:38 pm

    The reason is window.location.protocol already includes a colon (:).

    The host variable therefor contains http:://mysite.com

    jQuery picks up that you didn’t pass a full valid URL, so it prepends your hostname automatically.

    The fix is changing

    var host = window.location.protocol+"://"+window.location.hostname;
    

    to

    var host = window.location.protocol+"//"+window.location.hostname;
    

    Edit

    I created a jsfiddle with your code: http://jsfiddle.net/xH5ZV/

    and the fixed code: http://jsfiddle.net/xH5ZV/1/

    Notice in the fixed code you don’t get the hostname twice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My website URL is http://www.hentaireader.com At the bottom right corner, I wish to put
I have a very simple ajax request: $.get(url, data) .done(function () { }) .fail(function
I have the following simple jquery snippet $(document).ready(function () { $.ajax({ url:myjson.json, dataType: 'json',
I have a very simple test page at http://student.cqu.edu.au/s0147794/ . It has an og:url
I have used the signalR chat app (as laid out in this tutorial http://sergiotapia.com/2011/09/signalr-with-mvc3-chat-app-build-asynchronous-real-time-persistant-connection-websites/
I have this code sample (written by someone else) that parses the website, and
I use DNOA for authentication + authorization with google in my website. http://ugi-2.apphb.com/Authentication.htm When
I have website developed in classic ASP . The URL is not SEO friendly
I have a very simple jQuery/ajax script for a membership driven website. The script
I'm using Apache and I have a sample web folder on my Local Host

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.