Revision: 40464
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 2, 2011 11:04 by dropthenerd
Initial Code
<?php
$answer = $_POST['answer'];
if($answer == '8'){
echo json_encode(
array(
'success' => 1,
'message' => 'Correct! 3 + 5 = 8'
)
);
exit();
}else{
echo json_encode(
array(
'success' => 0,
'message' => 'Sorry, that is the wrong answer.'
)
);
exit();
}
// just to have an extra failsafe!
echo json_encode(
array(
'message' => 'You must choose a valid response.'
)
);
Initial URL
http://www.dropthenerd.com/ajax-a-simple-approach-that-you-will-use-and-reuse/
Initial Description
Initial Title
Example of a JSON encoded repsonse
Initial Tags
json
Initial Language
PHP