Relative Path Problems in Javascript Ajax call

后端 未结 5 731
深忆病人
深忆病人 2020-12-10 02:14

Okay, I have a JavaScript file with the following functions:

function AskReason() {
    var answer = prompt(\"Please enter a reason for this action:\", \"\")         


        
5条回答
  •  [愿得一人]
    2020-12-10 03:02

    Paths that start with a "/" (and no protocol & host) are relative to the root of the host. If you deploy such that your application is at "http://whatever/myapp", then your root-relative paths have to start with "/myapp".

    When you're working in a server-side environment that involves some sort of page template mechanism, a common trick is to have that part of the path be some kind of configuration variable so that you can write pages with paths like:

    click me
    

    Then that "root" variable is expanded based on configuration to "/myapp" or whatever.

提交回复
热议问题