user1762634
user1762634

Reputation:

AngularJS JavaScript reading file from parent directory

Does anyone know how to get file from parent directory using $http.get?

The system works fine if I use $http.get("customers.php") (file customers.php produce json format data) where customers.php is in same directory but if I switch customer to parent directory, system doesn't work (using this expression $http.get("../customers.php") ).

I only use AngularJS.

Upvotes: 2

Views: 2692

Answers (2)

Ignjatije
Ignjatije

Reputation: 126

I'm quite sure that answer you get is not a solution for your problem. If it is true what you said, when file customers.php is not in the root of web directory, which means is hidden from url, then you can not solve problem with the help of $http.get function. Suppose that we have

/var/www/public directory

and the file customers.php is in next directory

/var/customers.php

Your root directory of your web server is

/var/www/public

with your AngularJS files, like *.html or customers.html.

If someone enter this url

www.serverip.com 

Your web server point to this directory /var/www/public/customers.html and you want to read file from /var/customers.php with $http.get fuction.

You can not do that.

You must put customers.php in the root of your web server. For instance, in the next directory

/var/www/public/customers.php

Thanks for your attention.

Upvotes: 0

Masum Billah
Masum Billah

Reputation: 2399

Best practices will be provide complete URL.

Such As:

$http.get("http://example.com/customers.php")

Or you can use ../ instead of it.

Upvotes: 2

Related Questions