jquery ajax & full server path

后端 未结 3 1900
一向
一向 2021-01-15 15:52

Is there a way to use a full server path instead of a url when submitting a form via ajax with jquery?

The exemple below doesn\'t work but it will give you an idea o

相关标签:
3条回答
  • 2021-01-15 16:16

    Is there a way to use a full server path instead of a url when submitting a form via ajax with jquery?

    You can use location to get the current server:

    url: location.protocol + "//" + location.host + "/home/full/server/path/file.php"
    

    But you cannot use absolute path for cross-domain requests.

    0 讨论(0)
  • 2021-01-15 16:27

    Web servers do not work this way. There are obvious security reasons why. You can use a relative path though.

    0 讨论(0)
  • 2021-01-15 16:28

    No, that won't work. Those are not publicly visible URIs, those are actual script paths which are not visible from the client.

    0 讨论(0)
提交回复
热议问题