简体   繁体   中英

javascript form submit is not working in https

javascript submit is not working in https.

javascript code

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

html code

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

result of newtwork capture on IE developer tool,

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

on Load(event) break

This code is working normally on 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%>" ?

<%= {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.

Second, you don't need to set the action for the form again in javascript since it's already set in 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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