从 Chrome 控制台向 wamp localhost 发送 XHR 请求

Send XHR request from Chrome console to wamp localhost

我试图通过 XHR 请求从 Chrome 控制台向本地主机发送 JSON 我的 handler.php 我将 XHR url 设置为 localhost/handler.php,但它不起作用。它只是附加到当前 url.

的末尾
www.current-url.com/something/text/localhost/handler.php

URLs 101:如果您在网站“http://example.com/subdir”上,那么各种 URL 类型的解释方式如下:

relative:             foo.html                    -> http://example/subdir/foo.html
relative:             ../foo.html                 -> http://example.com/foo.html
relative:             ../otherdir/foo.html        -> http://example.com/otherdir/foo.html
local absolute:       /foo.html                   -> http://examle.com/foo.html
local relative:       google.com/hi/mom/foo.html  -> http://example.com/subdir/hi/mom/foo.html
local absolute:       /google.com/hi/mom/foo.html -> http://example.com/google.com/hi/mom/foo.html
universal absolute:   http://google.com/kittens   -> http://google.com/kittens

换句话说,如果您希望 URL 被解释为其他方面,则它必须是 "universal absolute" 并包含完整的 url:protocol://host/path.