<form id="msform" action="AN HTTP to AGENT" method="post">
如果我发布这些形式发送JSON的服务:如何发送JSON字符串,而不是URL字符串
$("#msform").submit(function(){
// construct an HTTP request
var xhr = new XMLHttpRequest();
xhr.open(form.method, form.action, true);
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
// send the collected data as JSON
xhr.send(JSON.stringify($('#msform').serializeObject()));
xhr.onloadend = function() {
// done
};
});
但在我的数据库中,我能看到这样的信息:
customerName=a&email=asd%40asd.com&phoneNumber=a&orderReference=a&item1=&amount1=&item2=&amount2=&item3
我最终想保存这一点,像这样:
{"customerName":"[email protected]","email":"[email protected]",
"phoneNumber":"[email protected]","orderReference":"
我的问题是:
- 我该怎么做?
- 区别是什么?
这是你的实际网址? 'action =“HTTP to AGENT”' –
没有它的一个真正的http,但我想保持私有 – YdB