如何在inappbrowser Cordova App中使用https发布请求

时间:2018-09-26 14:36:53

标签: angular typescript cordova

用于在脚本变量中使用选项Json转换帖子正文的代码

var options = {
      key: this.merchant_key,
      productinfo: this.productinfo,
      hash: this.hash,
      txnid: this.tran_id,
      amount: this.paymentAmountDisplay,
      service_provider:this.service_provider,
      surl: this.successURL,
      furl: this.failureURL,
      curl: this.cancelURL,
      firstname: this.firstname,
      email: this.email,
      phone:this.phone,
      udf1: this.owner_id,
      udf2: this.customer_number,
      udf3: this.payment_id,
      udf4: this.bill_id,
      udf5: this.cableName_display,
      udf6:this.calculatedDueAmount
  };    

 var script = 'var form = document.createElement("form");';
      script += 'var url = "https://secure.payu.in/_payment";';
      script += 'form.method="post"';
      script += 'form.setAttribute("action",url);';
     for (var data in options) {
       script += 'var hiddenField = document.createElement("input");';
       script += 'hiddenField.setAttribute("type", "hidden");';
       script += 'hiddenField.setAttribute("name","' + data +'");';
       script += 'hiddenField.setAttribute("value","' + options[data] + '");';
       script += 'form.appendChild(hiddenField);';
     }

代码,用于使用选项Jason转换脚本变量中的帖子正文

script += 'document.body.appendChild(form)';
var ref = cordova.InAppBrowser.open('Url','_blank','location=yes');
script += 'form.submit();';

ref.addEventListener('loadstop', onLoadStopFunction);

function onLoadStopFunction(){
  console.log('onLoadstop in function',script);
   ref.executeScript({ code: script }, function() {
});
   ref.show();   
  }

我正在尝试将InObjectBrowser中的Post对象传递给Url,Url正在打开,但是,我通过Url发送的正文内容没有收到,所以请帮助我...

0 个答案:

没有答案