Answer the question
In order to leave comments, you need to log in
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>
$(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;
});
});
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"];
...дальше я их сохраняю в файл.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question