|
|
if (isset($_POST['felt01'],$_POST['felt02'], $_POST['felt03'])) { print_r($_POST); } |
<form action="add.php" method="post"> <input type="text" name="first">+ <input type="text" name="second"> <input type="submit" value="Send"> </form> |
$('#add').on('submit', function() { var that = $(this), contents = that.serialize(); $ajax({ url: 'add.php', dataType: 'json', type: 'post', data: contents, success: fundtion(data) { if(data.success) { alert('The result is ' + data.result); } } }); return false; }); |
<?php header('Content-type: text/javascript'); $json = array( 'success' => false, 'result' => 0 ); if(isset($_POST['first'], $_POST['second'])) { $first = (int)$_POST['first']; $first = (int)$_POST['second']; $json['success'] = true; $json['result'] = $first + $second; } echo json_encode($json); ?> |
https://www.youtube.com/watch?v=GrycH6F-ksY