2017-04-21 1 views

Antwort

1

Ich würde jQuery verwenden.

$("#submit").on("click", function(){ 
 
    $.ajax({ 
 
\t \t \t type: "post", 
 
\t \t \t url: "process.php", 
 
\t \t \t data:"action=SomeActionHere", 
 
\t \t \t success: function(data){ 
 
\t \t \t \t alert("SUCCESS"); 
 
\t \t \t }, 
 
\t \t \t error: function(e){ 
 
\t \t \t \t alert("ERROR"); 
 
\t \t \t } 
 
\t \t }); 
 
};
<!--index.html --> 
 
<button id="submit">GOGO</button> 
 

 
<!--process.php--> 
 

 
<?php 
 
header("Content-type: application/json; charset=utf-8"); 
 
//connecto to server 
 

 
$action = $_POST['action']; 
 

 
if($action == "SomeActionHere"){ 
 

 
// do you sql stuff here 
 

 
// when done sql 
 
echo json_encode("SUCCESS"); // whatever data you want to send back 
 

 
} 
 

 
?>

Verwandte Themen