$("#seuFormulario").submit(function(event) { event.preventDefault(); $.ajax({ type: "POST", url: "api_order.php", // Aponta para o arquivo que criamos data: $(this).serialize(), success: function(response) { if (response.success) { Swal.fire({ icon: 'success', title: 'Pedido Realizado!', text: 'ID do Pedido: ' + response.order_id, confirmButtonText: 'OK' }); } else { Swal.fire({ icon: 'error', title: 'Falha no Pedido', text: response.message, confirmButtonText: 'OK' }); } }, error: function() { Swal.fire({ icon: 'error', title: 'Erro', text: 'Não foi possível se comunicar com o servidor.' }); } }); });