Skip to content
abdur-developerPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 

Repository files navigation

1. fetching in javascript

fetch('complete.php', {
        method: 'POST', // HTTP method
        headers: {
            'Content-Type': 'application/json', // Specify the content type
        },
        body: JSON.stringify({
            key1: 'value1',
            key2: 'value2'
        }) // Data to send
    })
    .then(response => {
        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
        }
        return response.json(); // Parse JSON response
    })
    .then(data => {
        console.log('Success:', data);
    })
    .catch(error => {
        console.error('Error:', error);
    });

2. Received in php

<?php
$rawData = file_get_contents("php://input");

$data = json_decode($rawData, true);

$key1 = $data['key1'] ?? null;
$key2 = $data['key2'] ?? null;

header('Content-Type: application/json');
echo json_encode([
    'status' => 'success',
    'receivedKey1' => $key1,
    'receivedKey2' => $key2
]);
?>

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors