javascript - 表单未发布到 iframe 返回

标签 javascript authorize.net

这本来应该非常简单,但我花了几个小时试图弄清楚为什么一个简单的表单帖子不会以 iframe 而不是新窗口结束。

我正在尝试将数据发布到 authorize.net,我希望响应返回到 iframe 中。但是它会打开一个新窗口。我不知道还能做什么。这是我的代码

<html>  
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
            document.getElementById("test-form").submit();
    });
    </script>
</head>
<body>  

   <form method="post" name="test-form" id="test-form" target="myIframe" action="https://test.authorize.net/gateway/transact.dll">
   <input type="text" name="x_login">
   <input type="text" name="x_fp_sequence">
   <input type="text" name="x_fp_timestamp">
   <input type="text" name="x_amount">
   <input type="text" name="x_fp_hash">
   <input type="text" name="x_show_form">
   <input type="text" name="x_test_request">
   <input type="text" name="x_type">
   <input type="text" name="x_currency_code">
   <input type="text" name="x_invoice_num">
   <input type="text" name="x_description">
   <input type="text" name="x_first_name">
   <input type="text" name="x_last_name">
   <input type="text" name="x_company">
   <input type="text" name="x_address">
   <input type="text" name="x_city">
   <input type="text" name="x_state">
   <input type="text" name="x_zip">
   <input type="text" name="x_country">
   <input type="text" name="x_phone">
   <input type="text" name="x_email">
   <input type="text" name="x_relay_response">
   <input type="text" name="x_solution_id">
   </form>
   <iframe src="" name="myIframe></iframe>  

</body>  



</html>  

最佳答案

通过将您的代码放入 Plunker,第 37 行出现语法错误:

<iframe src="" name="myIframe></iframe>  
                             ^-- missing "

添加结束引号后,我可以在 iFrame 中看到加载的页面 :) https://embed.plnkr.co/aM5EsESHODV8nPbVhyK8/

您可能需要考虑更改为使用可以帮助您识别打字错误的 IDE,从而节省时间。

关于javascript - 表单未发布到 iframe 返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38943480/

相关文章:

javascript - 从 TypeScript 中的重写接口(interface)自动推断类型

javascript - 我需要在外部脚本和样式表中使用 rel ="nofollow"吗?

javascript - noUiSlider 更改幻灯片上的范围

php - 使用 CURLOPT_SSL_VERIFYHOST 的替代方案,2

e-commerce - Authorize.net CIM 的替代方案

javascript - 如何在不同操作系统上使用源映射文件

javascript - 谷歌地图 - map 未加载

e-commerce - Authorize.Net Silent Post 如何工作?

java - E00011 - 访问被拒绝。您无权调用交易详情 API。 - 在 Aithorize.net

java - Authorize.net DPM——在servlet而不是jsp中执行服务器端处理