问题
When testing an Excel Web Add-in that has an HTML form that POSTs
to httpbin Request & Response Service, the form is not being sent.
I am using Excel 2016 for Mac version is 15.39 (171010) running on High Sierra ver 10.13.1. I have seen the same issue with Excel for iPad.
Are Excel Add-ins incompatible with Excel 2016 for Mac and iPad when using POST
method for forms?
There is a call to the site and page opens in a browser. However, there is no POST
. This is what we see on the httpbin.org
page – note the method GET
and no parameters and their values seen:
{
"Host": "httpbin.org",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"
"method": "GET",
"origin": "<ip-address-here>",
"url": "https://httpbin.org/anything"
}
Using this:
<script type="text/javascript">
$("#testForm").submit();
</script>
<form method="POST" id="testForm" action="https://httpbin.org/anything" accept-charset="UTF-8" target="_blank">
<input type='hidden' name='mergeDataFormat' value='csv'>
<input type="hidden" name="mergeData" id="mergeData" value='Name,Street,"City, State",ZIP Code'>
<input type="submit" value="Send" id="submitForm" />
</form>
Please refer to this post for more details: Why doesn’t the form not POST in Excel 2016 for Mac?
The AppDomain
was set to the following:
<AppDomains>
<AppDomain>https://httpbin.org/</AppDomain>
</AppDomains>
Tried with an onsubmit
handler as shown below but I see no change.
<form method="POST" id="testForm" onsubmit="datasubmit()" action="https://httpbin.org/anything" accept-charset="UTF-8" target="_blank"></form>
<script type="text/javascript">
function datasubmit() {
console.log("Your details have submitted..........");
}
</script>
The same code works fine when tested in a browser, outside of Excel 2016 for Mac. Also works fine in Excel Online. Only fails inside Excel 2016 for Mac.
回答1:
I believe this is related to the usage of relative path in the AppDomain segment of the add-in manifest. The relative paths such as https://httpbin.org/anything
is not allowed and instead you'd need to just use the domain name https://httpbin.org/
. Do you need to open the new window as part of the app or could you post the form to a different frame? In other words, could you explain the desired behavior of the form and post actions?
来源:https://stackoverflow.com/questions/47683237/unable-to-post-form-from-excel-2016-for-mac-or-excel-for-ipad