Error Message jQuery Program

Error Message jQuery Cognizant Handson Program

Create an HTML page that should display the error status message when the user clicks the button ‘Click to Get the Employee Data’  with the id “btn-id” to load the JSON file ‘employee.json’ does not exist.  Use jquery ajax() to perform the task.  Display the error message “Error Message: Not found” in a div tag with the id ‘err-id’.

 Note:

1. Do not alter the files employee.html
2. Write your code in employee.js file
3. Avoid writing the jQuery ‘document ready’ method for the proper web page visibility.
4. Do not use ‘ES6’ features.

employee.js

//WRITE YOUR jQUERY CODE HRE

$('#btn-id').click(function(){
    $.ajax({
        url: 'employee.json',
        error:function(){
            $('#err-id').html("Error Message: Not found");
        }
    })
})

Similar Posts