Relative Path Problems in Javascript Ajax call

后端 未结 5 748
深忆病人
深忆病人 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:01

    The url

    var url = "/Shared/AskReason.ashx?REASON=" + reason; 
    

    Is looking for the file in the root directory [since it is an absolute path], effectively

    http://localhost/Shared/AskReason.ashx
    

    You should include the name of the virtual directory OR determine the appropriate structure:

    Starting without the / will give you a relative path ... if you need to navigate directories use ../Shared/ style of notation, or finally use your servers Directory command to determine your current path.

提交回复
热议问题