我想在JavaScript中使用XMLHttpRequest发送一些数据.
假设我在HTML中有以下表单:
<form name="inputform" action="somewhere" method="post">
<input type="hidden" value="person" name="user">
<input type="hidden" value="password" name="pwd">
<input type="hidden" value="place" name="organization">
<input type="hidden" value="key" name="requiredkey">
</form>
Run Code Online (Sandbox Code Playgroud)
如何在JavaScript中使用XMLHttpRequest编写等效代码?
我有一些数据需要转换为JSON格式,然后用JavaScript函数POST它.
<body onload="javascript:document.myform.submit()">
<form action="https://www.test.net/Services/RegistrationService.svc/InviteNewContact" method="post" name="myform">
<input name="firstName" value="harry" />
<input name="lastName" value="tester" />
<input name="toEmail" value="testtest@test.com" />
</form>
</body>
Run Code Online (Sandbox Code Playgroud)
这是帖子现在的样子.我需要它以JSON格式提交值并使用JavaScript进行POST.