“PHP Return JSON -Antwort mit Statuscode zurück” Code-Antworten

PHP Return JSON -Antwort mit Statuscode zurück

header('Content-type: application/json');
http_response_code(200);
echo json_encode([
	'message' => 'thanks'
]);
Silly Skunk

PHP gibt eine JSON -Antwort zurück

//PHP File
<?php
$data = /** whatever your data are **/;
header('Content-Type: application/json; charset=utf-8');
echo json_encode($data);

//In JS File
//JQUERY AJAX
        $.ajax({
        url: "path/to_php_file.php",
        dataType: "json",  
        type: "GET",
        data: {datax : datax },
Trevorpergliamici

Ähnliche Antworten wie “PHP Return JSON -Antwort mit Statuscode zurück”

Fragen ähnlich wie “PHP Return JSON -Antwort mit Statuscode zurück”

Weitere verwandte Antworten zu “PHP Return JSON -Antwort mit Statuscode zurück” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen