首页 > 解决方案 > 如何使用 inappbrowser ionic 4 发送帖子数据

问题描述

我需要知道如何通过邮寄方式将数据发送到作为支付网关inappbrowser的外部url

我正在处理ionic执行脚本的属性但是我没有设法传递发布数据,我想看看是否有其他方法但我需要使用inappbrowser

 let options: InAppBrowserOptions={
      zoom:'no',clearcache:'yes',hidden:'yes',hidenavigationbuttons:'yes',hideurlbar:'yes'
    };
    let customheader= 'foo:123,bar:456';
    const browser= this.iab.create('https://url_anyway','_blank',options);
    browser.on('loadstop').subscribe( (ev: InAppBrowserEvent) => {
      browser.executeScript({code: "(function() {const data = new FormData(document.getElementById('mp_account'));fetch('https://url_anyway', {   method: 'POST',   body: data}).then(function(response) {   if(response.ok) {       return response.text()   } else {       throw 'Error en la llamada Ajax';}}).then(function(texto) {   console.log(texto);}).catch(function(err) {   console.log(err);});  })()"}).then( function(){
        setTimeout(function(){
          browser.show();
        ;}, 1500);

      }); 
    });

通过 post 方法打开 url 时不显示任何内容

标签: ionic-frameworkionic4inappbrowser

解决方案


推荐阅读