Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在应用程序内浏览器中打开表单操作提交?_Javascript_Android_Ionic - Fatal编程技术网

Javascript 如何在应用程序内浏览器中打开表单操作提交?

Javascript 如何在应用程序内浏览器中打开表单操作提交?,javascript,android,ionic,Javascript,Android,Ionic,我正在使用Ionic应用程序构建一个android应用程序 我有一个带有隐藏元素的html表单,通过javascript提交(通过模拟隐藏的提交按钮单击) 这将重定向到“支付网关”页面 以下是我需要实现的目标: 保持HTML表单不变,我需要在Ionic in-app浏览器中打开表单操作中指定的url 我有两个限制: 我必须使用HTML表单和表单操作 我正在使用WebSocket,因此我需要打开应用程序内浏览器,以便套接字连接在后台保持打开状态 代码如下: HTML格式: <form act

我正在使用Ionic应用程序构建一个android应用程序

我有一个带有隐藏元素的html表单,通过javascript提交(通过模拟隐藏的提交按钮单击)

这将重定向到“支付网关”页面

以下是我需要实现的目标: 保持HTML表单不变,我需要在Ionic in-app浏览器中打开表单操作中指定的url

我有两个限制:

  • 我必须使用HTML表单和表单操作
  • 我正在使用WebSocket,因此我需要打开应用程序内浏览器,以便套接字连接在后台保持打开状态
  • 代码如下:

    HTML格式:

    <form action='https://secure.payu.in/_payment' method="POST">
      <input type="hidden" name="firstname" id="payu_data.firstname" ng-model="payu_data.firstname"/>
      <input type="hidden" name="surl" id="payu_data.surl" ng-model="payu_data.surl">
      <input type="hidden" name="furl" id="payu_data.furl" ng-model="payu_data.furl">
      <input type="hidden" name="phone" id="payu_data.phone" ng-model="payu_data.phone"/>
      <input type="hidden" name="key" id="payu_data.key" ng-model="payu_data.key"/>
      <input type="hidden" name="hash" id="payu_data.hash" ng-model="payu_data.hash"/>
      <input type="hidden" name="service_provider" id="payu_data.service_provider" ng-model="payu_data.service_provider"/>
      <input type="hidden" name="txnid" id="payu_data.txnid" ng-model="payu_data.txnid"/>
      <input type="hidden" name="productinfo" id="payu_data.productinfo" ng-model="payu_data.productinfo"/>
      <input type="hidden" name="amount" id="payu_data.amount" ng-model="payu_data.amount"/>
      <input type="hidden" name="email" id="payu_data.email" ng-model="payu_data.email"/>
      <!--<input type="hidden" name="udf1" id="payu_data.udf1" value="buy_subscription" />-->
      <input type= "submit" value="submit" id="id_payu_submit_button" hidden>
    </form>
    
    // submit payu form
                document.getElementById("id_payu_submit_button").click();
    
                // initiate websocket
                var socket = DOMAIN.socket + API_URLS.billingInitiationSocket;
                var connection = new WebSocket(socket);
    
                // When the connection is open, send some data to the server
                connection.onopen = function () {
                  // Send the message 'Ping' to the server
                  connection.send(userService.userSession.user_data.token); 
                };
    
                // Log errors
                connection.onerror = function (error) {
                  console.log("Error in initiating billing socket: " + error);
                };
    
                // Log messages from the server
                connection.onmessage = function (e) {
    
                  console.log('Server: ' + e.data);              
                  var data = JSON.parse(e.data);
                  console.log("Websocket received data: " + JSON.stringify(data));
    
                  if (data.hasOwnProperty("redirect") && data.redirect===true){
                    $state.go("app.home");
                    alert("Something happened!");
                  }
    
                };