Sometimes, data returned from the server is not defined which results in the following appearing on my page:
<p id="element">undefined</p>
My AJAX success function:
success: function( data ) {
$( '#element' ).text( data.message )
}
PHP handler:
$response = array()
// Some logic which may assign data to $response['message']
echo json_encode( $response );
die;
Is there a way to suppress such undefined messages?