我有一个包含行
的JQuery脚本console.log("Killing "+selected)
$.post("http://127.0.0.1:8080/delete_birloki",{ birloki: selected})
并记录......
Killing france
Golang处理程序以
开头func deleteBirloki(rw http.ResponseWriter, req *http.Request) {
dat,err := httputil.DumpRequest(req,true)
if err != nil {
fmt.Fprintf(rw,"BAD")
return
}
fmt.Println(string(dat))
,打印输出
POST /delete_birloki HTTP/1.1
Host: 127.0.0.1:8080
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Cookie: weve_been_here_before=true; _ga=GA1.1.606577919.1412775218
Origin: http://127.0.0.1:8080
Referer: http://127.0.0.1:8080/config/?birloki=&north=&east=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36
X-Requested-With: XMLHttpRequest
birloki%5B%5D=france
有人可以解释为什么变量名已被更改? 在类似的情况下,我可以用
请求“birloki []”birloki := req.PostFormValue("birloki[]")
但即使这样在这种情况下似乎也不起作用
答案 0 :(得分:1)
由于Javascript的可爱无类型特性,我发布的变量有时是一个字符串,有时候是一个数组。
当它出现在[]时,它当然是一个数组: - (