<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