Answer the question
In order to leave comments, you need to log in
After updating the browser did not send data?
Good afternoon, who will tell you, there is a form with a submit button, there is a js code.
JS code processes the form without reloading the ajax page and submits the data after 1 second.
JS
$(document).ready(function(){
$("#form").submit(function() {
var form_data = $(this).serialize();
$.ajax({
type: "POST",
url: "api.php",
data: form_data
});
});
setTimeout(function(){
$("#button").trigger('click');
}, 1000);
});
<form id="form" action="javascript:void(null);" method="post" style="display: none;">
{assign var="num" value="0"}
{foreach $purchases as $purchase}
<input type="text" name="data1[{$num+1}]" value="{$purchase->variant->sku|escape}">
{assign var="num" value=$num+1}
{/foreach}
{assign var="num" value="0"}
{foreach $purchases as $purchase}
<input type="text" name="data2[{$num+1}]" value="{$purchase->amount}">
{assign var="num" value=$num+1}
{/foreach}
<input type="text" name="data3" value="{$order->name|escape}">
<input type="text" name="data4" value="{$order->phone|escape}">
<input type="text" name="data5" value="{$order->address|escape}">
<input type="text" name="data6" value="{$order->comment|escape|nl2br}">
<input type="text" name="data7" value="{$order->date|time}">
<input type="submit" id="button" value="Отправить">
</form>
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