ajax如何调用wfv,如何使用golang解析POST AJAX数据?

我使用AJAX这样的数据发送到golang应用:如何使用golang解析POST AJAX数据?

httpRequest = new XMLHttpRequest();

if (!httpRequest) {

document.getElementById("errorArea").innerText = "Giving up :(Cannot create an XMLHTTP instance'";

}

url = "http://127.0.0.1:8080/putContent?url="+window.location.pathname;

httpRequest.onreadystatechange = sendContents;

httpRequest.open('POST', url);

httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

var fd = new FormData();

fd.set ("data",document.getElementById("ta").value);

httpRequest.send(fd);

和后端是这样的:

r.ParseForm()

fmt.Print("postform=")

fmt.Println(r.PostForm)

结果(与sdfsdf键入到textarea的TA):

postform=map[------WebKitFormBoundarytZ4Y8wFVKpWBWBnu

Content-Disposition: form-data:[] name:["data"

sdfsdf

------WebKitFormBoundarytZ4Y8wFVKpWBWBnu--

]]

------------

编辑

发现的problem.The问题是FORMDATA发送数据curl -H 'Content-type: application/x-www-form-urlencoded' --data $'------WebKitFormBoundaryiVVK2EjSLDbqaccx\r\nContent-Disposition: form-data; name="data"\r\n\r\nsdfsdf\r\n------WebKitFormBoundaryiVVK2EjSLDbqaccx--\r\n' --compressed

,而不是`卷曲--data“数据= sdfsdf”

现在,真正的问题是如何如何得到FORMDATA发送正常数据?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值