jQUERY get the parent folder of url

I want to use Ajax to load an xml file. This file is located into another folder of the root directory.

  1. How do I get the root directory path with jQuery?
  2. How do I move to the parent directory of the current path with jQuery?

Upvotes: 2

Views: 6420

Answers (1)

Identity1
Identity1

Reputation: 1155

This returns the root/hostname:

window.location.hostname

This returns the path of parent folder.

var string1 = "../example/index.html";
var string2 = string1.replace(string1.split("/").pop(),"");

string2=../example/

Upvotes: 1

Related Questions