-1

I am posting to a payment api that returns html content of a payment page where a user can select mode of payment. I want this payment page to be displayed on an iframe within the current page

<iframe name="pay-frame" src="" id="pay-frame" width="720" height="600" 
  style="border: none;"></iframe>

The payment page content is returned from this

$('#make-payment').click(function (e){
    e.preventDefault();
    $.ajax({
        type        :   'POST',
        url         :   'url',
        data        :   postData,
        dataType    :   'json',
        encode      :   true             
    })
    .done(function(data){
        // The response data is a payment page that I want displayed in an iframe
        console.log(data); 
    })
    .fail(function(data){
        console.error(data);
    });
});
rufusy
  • 107
  • 1
  • 10
  • Does this answer your question? [jQuery changing contents of an iFrame](https://stackoverflow.com/questions/9490907/jquery-changing-contents-of-an-iframe) – Justinas Aug 13 '23 at 18:02
  • 1
    _But_ you specify `dataType: 'json'` - means you expect JSON from API response and will fail if it's HTML instead, so are you sure about your requirements? – Justinas Aug 13 '23 at 18:04
  • @Justinas the link you provided answered my question – rufusy Aug 13 '23 at 20:45

0 Answers0