G
G
gawrilow682018-12-17 12:00:43
phonegap
gawrilow68, 2018-12-17 12:00:43

How to pass post to PhoneGap?

Good afternoon, please tell me how to perform the data transfer from the form.
index page

<form name="MyForm"  id="callbacks" method="post"><!--Атрибут action остается пустым-->
  <input name="name" type="text" placeholder="Имя" /><br>
  <input name="tel" type="phone" placeholder="Телефон" /><br>
  <textarea name="body"  placeholder="Ваше сообщение"></textarea><br>
  <input type="submit" value="Отправить заявку" id="btncontcall" />
</form>

js file
$(document).ready(function() {
    $('body').on('submit', "#callbacks", function(e){ 
      var form = $(this).serialize();
     
      e.preventDefault();
      $.ajax({
        type: "POST",
        url: "http://*********/send.php", // Адрес обработчика
        data: form,
        
        error:function(){
           
          $("#erconts").html("Произошла ошибка!");},
        beforeSend: function() {
          $("#erconts").html("Отправляем данные...");
        },
        success: function(result){
         
          $("#erconts").html(result);
          checkThis();
        }
      });
      return true;
    });
  });

send.php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST,GET,OPTIONS');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
header('Content-Type: application/json');
 $a = $_POST["name"];
 $phone = $_POST["tel"];
 $body = $_POST["body"];
...дальше я их сохраняю в файл.

In the web version, everything is fine, data is sent from the computer, but when I start it from a mobile phone, nothing happens. What could be the problem? Which way to dig..

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question