开发者

Inserting an IFrame in a DIV with an Ajax response

I have a web site and I need that my users are able to make a payment and the web has it own page where its divided into 3 sections. The first one is for choosing the payment method(Visa, Mastercard, etc...) the second one is an inputbox where the user enters the amount to transfer and a button to proceed with the load of the Moneybookers payment gateway. Well, In the third section there is an empty DIV waiting for load until the user click on the transaction button. So, once this is done, I call a PHP via AJAX. The code of the AJAX function is the next one:

    var xml = null;
     try{
         xml = new ActiveXObject("Microsoft.XMLHTTP");
     }catch(expeption){
         xml = new XMLHttpRequest();
     }xml.open("POST", "mb_connect.php", false);
  xml.setRequestHeader("Content-Type", "applicati开发者_开发技巧on/x-www-form-urlencoded");
  xml.send("pay_to_email="+datos[3]+"&transaction_id="+datos[1]+
      "&status_url="+datos[2]+
      "&language="+lang+
      "&pay_from_email="+datos[13]+
      "&firstname="+datos[5]+
      "&lastname="+datos[6]+
      "&address="+datos[7]+
      "&postal_code="+datos[8]+
      "&city="+datos[9]+
      "&state="+datos[10]+
      "&country="+datos[11]+
      "&date_of_birth="+datos[12]+
      "&amount="+document.payment.cantidad.value+
      "&payment_methods="+datos[4]);

  $("#contenido").html(xml.responseText);

and the PHP called is this one:

    <?php header('Content-type: text/html; Charset=utf-8');

extract($_POST);
$status_url2  = 'mailto:payments@misite.com';
$return_url_target = 3;
$return_url   = 'https://www.misite.com';
$cancel_url   = 'https://www.misite.com';

?>


<iframe id="myiframe" name="myiframe" frameborder="no" style="height: 600px; width:735px;" scrolling = "auto">
</iframe>
<form name="oc" action="https://www.moneybookers.com/app/payment.pl" method="post" target="myiframe">

 <input type="hidden" name="pay_to_email"     value="<?= $pay_to_email ?>">
 <input type="hidden" name="recipient_description"   value="My SITE ltd">
 <input type="hidden" name="transaction_id"     value="<?= $transaction_id ?>">     
 <input type="hidden" name="status_url"      value="<?= $status_url ?>">
 <input type="hidden" name="status_url2"     value="<?= $status_url2 ?>">
 <input type="hidden" name="return_url_target"    value="<?= $return_url_target ?>">
 <input type="hidden" name="return_url"      value="<?= $return_url ?>">
 <input type="hidden" name="cancel_url"      value="<?= $cancel_url ?>">
 <input type="hidden" name="return_url_target"    value="1">
 <input type="hidden" name="cancel_url_target"    value="1">
 <input type="hidden" name="language"      value="<?= $language ?>">
 <input type="hidden" name="confirmation_note"    value="">
 <input type="hidden" name="pay_from_email"     value="<?= $pay_from_email ?>">
 <input type="hidden" name="title"       value="">
 <input type="hidden" name="firstname"      value="<?= $firstname ?>">
 <input type="hidden" name="lastname"      value="<?= $lastname ?>">
 <input type="hidden" name="address"      value="<?= $address ?>">
 <input type="hidden" name="postal_code"     value="<?= $postal_code ?>">
 <input type="hidden" name="city"       value="<?= $city ?>">
 <input type="hidden" name="state"       value="<?= $state ?>">
 <input type="hidden" name="country"      value="<?= $country ?>">
 <input type="hidden" name="date_of_birth"     value="<?= $date_of_birth ?>">
 <input type="hidden" name="amount"       value="<?= $amount ?>">
 <input type="hidden" name="currency"      value="EUR">
 <input type="hidden" name="rec_cycle"      value="day">
 <input type="hidden" name="payment_methods"    value="<?= $payment_methods ?>">
 <input type="hidden" name="submit_id"      value="Submit">

</form>
<script language="JavaScript">document.oc.submit();</script>

so, this script, when executed, call automatically the moneybookers payment gateway and return the HTML code that is inserted into the IFRAME.

Well, all this process work fine in all browsers except Internet Explorer. There is no error and the DIV is empty.

Does anyone know what could be the mistake?

I would appreciate any help.

Thanks.


Unless your original page was loaded in the same domain as moneybookers.com IE will see this as a security violation. Perhaps changing the document.domain when you load the iFrame and that may alleviate your problem.

Here's an good article about cross-domain communication with iFrames for further reading.

Good luck.


I once had this problem. It turned out that because the ajax requested page was on another domain POST request changed into a OPTION request and messed the things up. (just check the net table.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜