Skip to Content
Author's profile photo Former Member

Check JSON data length and Error property in Ajax call(SAPUI5).


Please find the below code that will help you to display a custom message to user if you are not finding any data from XSODATA service.


                url : “your URL”

                dataType : “json”,


                success : function(data, textStatus, jqXHR) { // callback  called when data is received


                   if (data.d.results.length == 0) { // if data length is 0 then it assumnes that No matching data found and append the message



                    } else {

                        // fill the received data into the JSONModel



                error : function(jqXHR, textStatus, errorThrown) {

                    $(‘#error’).show();     //This will help you to throw a message to the user if URL is not correct like (404,401 etc)





         <div id=’errorMsg’ class=”display”>

                <p>No Data Found</p>


        <div id=’error’ class=”display”>

                <p>404 No Found</p>




Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.