У меня есть запрос POST к index.php
:
$(document).ready(function(){
$("#btn-calc").click(function () {
let cityValue = $("#delivery_city").val(),
weightValue = $("#weight").val();
$.ajax({
type: "POST",
url: "index.php",
data: {
city: cityValue,
weight: weightValue
},
success: function () {
console.log("Success")
},
error: function () {
console.log("Fail")
}
})
})
});
Отправляет данные .delivery_calc
в скрипт PHP с именем index.php
. В index.php
мне нужно реализовать запрос к внешнему сервису. Запрос должен быть таким:
exercise.develop.maximaster.ru / сервис / доставка /? Город = Тула и вес = 150
То есть вы видите данные из запроса POST. Как передать его в запрос на внешний сервис? Заранее спасибо.
P.S. На данный момент index.php
выглядит так:
<?php
header('Content-Type: text/html; charset=utf-8');
require("read_cache.php");
$content = file_get_contents('cities.html');
$city_array = json_decode($content, true);
$price = file_get_contents('http://exercise.develop.maximaster.ru/service/delivery/');
$priceMsg = json_decode($price, true);
?>