我正在根据用户输入生成一个URL,并且html和java脚本在同一个文件中,java脚本函数在脚本标记中,
<form name="generate" action="javascript:openUrl" method="post" onSubmit="return createUrl()">
<table>
<tr><td>Select Instance :</td>
<td>
</td>
</tr>
<tr><td style="padding-bottom: 10px;">Email : </td><td><input type="text" style="width:300px;" name="email" ng-model="email" class="ticker-textbox" /></td></tr>
<tr><td style="padding-bottom: 10px;">Expiration Date: </td><td><input type="text" style="width:150px;" name="expiryDate" class="ticker-textbox" />mm/dd/yyyy</td></tr>
<tr><td style="padding-bottom: 10px;">First Name : </td><td><input type="text" style="width:300px;" name="firstName" class="ticker-textbox" /></td></tr>
<tr><td style="padding-bottom: 10px;">Last Name : </td><td><input type="text" style="width:300px;" name="lastName" class="ticker-textbox" /></td></tr>
<tr><td style="padding-bottom: 10px;">Generated URL :</td><td><input disabled type="text" style="width:800px;" name="genURL" class="ticker-textbox" /></td></tr>
<tr>
<td><input type="button" name="button" value="Generate URL" onclick="createUrl()"/></td>
<td><input type="button" name="open" value="Open URL" onclick="openUrl()"/></td>
</tr>
</table>
</form>
我无法将方法设置为POST,无论如何,它都将方法设置为GET。
我尝试使用jquery在创建URL函数中设置$ .post,但它表示$无法识别。
功能:
var createUrl = function () {
var url = document.generate.instance.value + '/user/remoteLogin.html?clientName=' + cn;
if (hasText(document.generate.expiryDate.value)) {
var expiryDate = urlEncode(document.generate.expiryDate.value);
url += ('&expirationDate=' + expiryDate);
window.key = window.key.substring(0, window.key.length - document.generate.expiryDate.value.length)
window.key += document.generate.expiryDate.value;
}
var decodedKey = decodeBase64(window.key);
if (hasText(document.generate.email.value)) {
var em = urlEncode(encrypt(decodedKey, document.generate.email.value));
em = em.trim();
url += ('&em=' + em);
}
if (hasText(document.generate.firstName.value)) {
var fn = urlEncode(encrypt(decodedKey, document.generate.firstName.value));
url += ('&fn=' + fn);
}
if (hasText(document.generate.lastName.value)) {
var ln = urlEncode(encrypt(decodedKey, document.generate.lastName.value));
url += ('&ln=' + ln);
}
document.generate.genURL.value = url;
return true;
}
}
var openUrl = function () {
location.href = document.generate.genURL.value;
return false;
}
}