
How to check ajax request is completed in jQuery
You can check ajax request is completed in jQuery using complete() and always() method. The .always() method replaces the deprecated .complete() method in latest versions of jQuery.
Answers 1
-
Ajax post request with done, fail and always method
<script> $.ajax({ url: "/ajax.php", method: "POST", data:{ id: 1 } }) .done(function(resp) { console.log(resp); }) .fail(function(xhr, status, error) { alert(xhr.statusText); }) .always(function(jqXHR, textStatus) { if (textStatus != "success") { alert("Error: " + jqXHR.statusText); //error is always called .statusText } else { alert("Success: " + jqXHR.response); //might not always be named .response } alert('AJAX call complete'); }); </script>
0
Random Code Snippet Queries: Jquery
- Ajax for multiple form
- JQuery find text and show as bold in html page
- How to preview image before uploading in jQuery
- Execute function after Ajax call is complete
- How to remove Choose File button in jquery
- Show loading icon on click submit button in jQuery
- Add and remove input fields on click button using jQuery
- How to use and purpose of localstorage in javascript
- How to get closest form input value in jQuery
- Mixed Content: The page at 'https://w3codegenerator.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint
- How to validate input type file size in jQuery for multiple records
- Preview image in base64 format using jQuery on change input file
- Ajax done fail ajaxcomplete in not a function
- JQuery append html to below the target element
- Jquery.validate.min.js:4 Uncaught TypeError: Cannot read properties of undefined (reading 'mode')
- How to reset form input element on click
- Get the href link on click anchor in javascript
- How to find closest upper element and append html to below it in jquery
- Enable click event on appended element using jQuery
- Preview image in BLOB URL format on choose file in jQuery
- Show and hide target element on click button using javascript/jquery
- Jquery-3.6.0.min.js CDN link
- How to create read more in jquery
- Uncaught TypeError: $.ajaxSetup is not a function
- Uncaught TypeError: $.ajax is not a function