简体   繁体   English

javascript表单提交无法在https中运行

[英]javascript form submit is not working in https

javascript submit is not working in https. javascript提交无法在https中运行。

javascript code javascript代码

function apply()
{
    document.fileinfo.action='<%=uploadJSP%>';
    // uploadJSP = https://localhost/upload.jsp
    document.fileinfo.submit();
}

html code HTML代码

<form name="fileinfo" action="upload.jsp" enctype="multipart/form-data" method="post">
...
</form>

result of newtwork capture on IE developer tool, 在IE开发人员工具上捕获newtwork的结果,

...
DOMContentLoaded (event)‎‎  + 184ms -   
Load (event)‎‎  + 197ms -

on Load(event) break on Load(event)break

This code is working normally on http (uploadJSP = http://loaclhost/upload.jsp ) 此代码在http上正常工作(uploadJSP = http://loaclhost/upload.jsp

I don't know what is wrong. 我不知道出了什么问题。
please advice for me to solve this problem 请指教我解决这个问题

Firstly, Have you tried printing the value of document.fileinfo.action in your first snippet after it has been assigned = "<%=uploadJSP%>" ? 首先,您是否尝试在第一个片段中分配= "<%=uploadJSP%>"后打印document.fileinfo.action的值?

<%= {code} %> is only processed when the server sends html documents, so if your script is in a separate file from your html, or your server doesn't process code in between <script> tags, then document.fileinfo.action = "<%=uploadJSP%>" instead of document.fileinfo.action = "https://localhost/upload.jsp" as intended. <%= {code} %>仅在服务器发送html文档时处理,因此如果您的脚本与html位于单独的文件中,或者您的服务器不处理<script>标记之间的代码,则document.fileinfo.action = "<%=uploadJSP%>"而不是document.fileinfo.action = "https://localhost/upload.jsp"

Second, you don't need to set the action for the form again in javascript since it's already set in html. 其次,您不需要在javascript中再次为表单设置操作,因为它已经在html中设置。 So, instead of worrying how you can pass the correct value in your first snippet, I would suggest removing the document.fileinfo.action = "<%=uploadJSP%>" line altogether. 因此,我建议您删除document.fileinfo.action = "<%=uploadJSP%>"行,而不是担心如何在第一个代码段中传递正确的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM