javascript window.location gives me a wrong url path when checking firebug

Posted by Elson Solano on Stack Overflow See other posts from Stack Overflow or by Elson Solano
Published on 2012-09-06T15:20:27Z Indexed on 2012/09/06 15:38 UTC
Read the original article Hit count: 194

Filed under:

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!

© Stack Overflow or respective owner

Related posts about JavaScript