2016-08-14 75 views
1

這應該是非常簡單的,但我花了幾個小時試圖找出爲什麼一個簡單的表單發佈不會最終在iframe而不是一個新的窗口。form not not to iframe back

我想發佈數據到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> 

回答

2

把你的代碼Plunker,有在第37行語法錯誤:

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

將平倉報價後,我可以看到頁面加載到iFrame中:) https://embed.plnkr.co/aM5EsESHODV8nPbVhyK8/

您可能要考慮更改爲使用IDE這可以幫助您識別錯別字,從而可以節省數小時。

+0

哈哈哈不敢相信! – Autolycus

1

您在iframe名稱末尾缺少雙引號。