Unable to POST <Form> from Excel 2016 for Mac or Excel for iPad [duplicate]

霸气de小男生 提交于 2019-11-28 11:21:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!