Skip to content

Instantly share code, notes, and snippets.

@gicolek
Created September 13, 2012 14:37
Show Gist options
  • Save gicolek/3714708 to your computer and use it in GitHub Desktop.
Save gicolek/3714708 to your computer and use it in GitHub Desktop.
Json Callback
// inside the .php file
{
//$mail = $_POST['mail'];
$date = $_POST['date'];
$success = true;
$response = json_encode(
array( 'success' => $success,
'mail' => 'mail',
'message' => 'test',
'date' => $date
) );
// response output
header( "Content-Type: application/json" );
echo $response;
exit;
}
// working js
$.post(PrayAjax.ajaxurl, {
action: "pray-date",
//nonce: WishAjaxRmSl.nonce,
//id: wlid
}, function(data) {
alert(data);
});
// not working js
$.ajax({
type: "POST",
url: PrayAjax.ajaxurl,
action: "pray-date",
dataType: 'json',
data: {
date: date,
calcMethod: calcMethod,
city: city
},
success: function(data) {
//alert("done");
alert(data);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment