Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

Hi,

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.

jQuery.ajax({

                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

                                               

                        $('#errorMsg').show();

                    } 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)

                }

            });

<html>

    <body>

         <div id='errorMsg' class="display">

                <p>No Data Found</p>

         </div>

        <div id='error' class="display">

                <p>404 No Found</p>

         </div>

    </body>

</html>

Labels in this area