L
L
lamarchand2019-07-23 13:50:57
PHP
lamarchand, 2019-07-23 13:50:57

How can I make an api request via ajax?

I have a site for sale, there is a filling form, in this form I have to write Invoice 111111/11, and when I write it, it should automatically check if there is such a number in index.php, I know what I need to connect for this
.change() jquery, I have already implemented this, but for some reason I can't call invoice in index.php to check the

code in index.php

<code>$url = "getinvoice/";
$api->post = array(
  'invoice' => 'СЧ-111111/11',
);
$vehicle = $api->sendrequest($url);
echo '<details><summary>getinvoice</summary>';
echo '<p><pre>';
print_r($api->post);
print_r($vehicle);
echo '</pre></p></details>';
exit;</code>



my form and ajax in payment.php
<form class="form1" method= "post">
 <label class="label2 invoice"><?php echo _("№ Счёта на оплату");?></label>
<input class=" field only-numeric input1 invoice" type="text" name="invoice" value="<?php ?>"/>
<label class="label2"><?php echo _("Сумма оплаты (рубль)");?></label>
<input class="field only-numeric input1" type="text" name="order[calcSum]" value="<?php echo htmlspecialchars($order->getCalcSum()); ?>" />

<script>
$.ajax({
type: "POST",
 url: "engine/index.php",
data: {
invoice: in,
id: 
 },
 success: function(invoice) {
if(invoice == 'СЧ-111111-11') {
  result = 'ok', val;
$("#call-popup .form").hide();
  dataLayer.push({'event': 'callback_sent'});
  } else {
 result = invoice;
  btn.prop("disabled", false).prop("value", oldBtnTitle);
  }
  $('#call-popup .note').html(result);
 }
 });           
</script>

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