0

So just a general question: if i have a file structure like this where i have an index page in the root folder along with a scripts folder, and in the scripts folder there are two scripts one a JS which is referenced in the index page, and the other PHP which is referenced from the js script:

root-folder:
--> index.html
--> scripts/
-----> myscript.js
-----> myscript.php

how should I access the php script from the js script using a relative url?

would it be: ./myscript.php or ./scripts/myscript.php

in other words is the relative url from the index file or the js file. thanks!

2
  • i believe ./myscript.php or just myscript.php. but it's funny, you could have figured that out yourself pretty quick. Commented Jun 5, 2012 at 3:11
  • The "./" can be omitted. Commented Jun 5, 2012 at 3:16

1 Answer 1

1

Since the javascript is operating in the scope of the page, not its physical location, the URL to the PHP would include /scripts/ in the path name.

Sign up to request clarification or add additional context in comments.

1 Comment

okay, i had an idea that that is what was happening but i wasn't sure, thanks for the useful response

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.