How to handle a blank row from the database?
<p>I have the following script which works as long as it is returned data:</p>

<pre><code>$(document).ready(function() {
    $.ajax({
        type: 'POST',
        url: 'notifications.asmx/GetNotifications',
        data: '{strUser: "pqr"}',
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        success: function( notifications ) {
            if( notifications !== null ) { //&lt;-- this makes no difference
                 alert( notifications.d[0].text ) ;
            } else {
                alert ( "null" );
            }
        },
        error: function(xhr, status, error) {
                 var err = eval("(" + xhr.responseText + ")");
                 alert(err.Message) ;
        }
    });
});
</code></pre>

<p>If data is not returned, I get the error:</p>

<pre><code>Uncaught TypeError: Cannot read property 'text' of undefined
</code></pre>

<p>I have tried wrapping it in various if statements checking for <code>null</code> values, but that does not make any difference.</p>
