Linux - Difference locationhostname location host, Location.hostname and location.host

Difference locationhostname location host

What is the difference between location.hostname vs location.host
 // Display Domain name and Port Number
 location.host == "http://w3calculator.com:8080"
 // Display Domain name only
 location.hostname == "http://w3calculator.com"


Using hostname:
In most of ajax post method we use path name, On such situation we use hostname and its file path error to resolve such issue,
  
 For example(login issues, like www. or without use www.)
 Syntax,
 var ajurl = "http://"+location.hostname+"/path/filename.php"; 
 var datas = "val=text";
 
 $.ajax({ 
 type:"POST",
 url:ajurl,
 data:datas,
 success:function(html)
 {
 alert(html);
 }
 });

The topic on Linux - Difference locationhostname location host is posted by - Math

Hope you have enjoyed, Linux - Difference locationhostname location hostThanks for your time

Tech Bluff