Found 10710 Articles for Web Development

How to register a handler to be called when the Ajax request begins using jQuery?

Manav Sarkar
Updated on 20-Jul-2022 12:44:56

453 Views

jQuery is a feature-rich JavaScript library. We can perform a lot of actions with the help of jQuery which would otherwise require writing large pieces of code. It makes DOM manipulation, event handling, animation, ajax, etc. very easy.In this tutorial, we will learn how to register a handler to be called when the first Ajax request begins using jQuery. Ajax requests are typically HTTP requests that are called by the browser for different tasks such as GET, POST, etc. So when the tasks are performed, we can register a handler using the ajaxStart() function of jQuery. This function is always ... Read More

How to register a handler to be called when all Ajax requests completed using jQuery?

Manav Sarkar
Updated on 20-Jul-2022 12:37:08

328 Views

In this tutorial, we will learn how to register a handler to be called when all Ajax requests are completed using jQuery. Ajax requests are typically HTTP requests that are called by the browser for different tasks such as GET, POST, etc. So when the tasks are performed, we can register a handler using the ,ajaxStop() function of jQuery.SyntaxUse the following syntax to register a handler after an ajax request −$(document).ajaxStop(function () {    console.log('Registered handler.') })Explanation − Suppose we have a GET request on an API. When the API returns a result, jQuery checks if any requests are pending ... Read More

How to register a handler to be called when all Ajax requests completed using jQuery?

Manav Sarkar
Updated on 20-Jul-2022 12:32:25

886 Views

In this tutorial, we will learn how to register a handler to be called when Ajax requests complete using jQuery. Ajax requests are typically HTTP requests that are called by the browser for different tasks such as GET, POST, etc. So when the tasks are performed, we can register a handler using the ajaxComplete() function of jQuery. This function is always triggered when the request is completed.SyntaxUse the following syntax to register a handler after every ajax request −$(document).ajaxComplete(function () {    console.log('Registered handler.') })Explanation − Suppose we have a GET request on an API. When the API returns a ... Read More

How to check the lock state of a callback list using jQuery?

Manav Sarkar
Updated on 20-Jul-2022 12:18:54

118 Views

In this tutorial, we will learn how to check the lock-state of a callback list using jQuery. The lock is a callback list in jQuery in the current state. We can toggle the lock state so that additional changes cannot be made unless required.SyntaxThe callbacks list is locked and checked as follows −// Get callbacks list at current state var callbacks = $.Callbacks() // Lock the callbacks list callbacks.lock() // Check callbacks is locked or not console.log(callbacks.locked())AlgorithmFirst we receive the callbacks list at the current state using the Callbacks() function.Then we lock it using the lock() function and ... Read More

How to attach a function to be executed before an Ajax request is sent using jQuery?

Manav Sarkar
Updated on 20-Jul-2022 09:29:30

1K+ Views

In this tutorial, we will learn How to attach a function to be executed before an Ajax request is sent using jQuery. Ajax requests are typically HTTP requests that are called by the browser for different tasks such as GET, POST, etc. So when the tasks are performed, we can register a handler using the ajaxSend() function of jQuery. This event is called by jQuery whenever an ajax request is to be made.SyntaxUse the following syntax to register a handler before an ajax request −$(document).ajaxSend(function () {    console.log('Triggered ajaxStart. Started Request') })We have an Ajax request. Before sending the ... Read More

How to add the previous set of elements on the stack to the current set in jQuery?

Manav Sarkar
Updated on 19-Jul-2022 13:00:27

192 Views

jQuery is a feature-rich JavaScript library. We can perform a lot of actions with the help of jQuery which would otherwise require writing large pieces of code. It makes DOM manipulation, event handling, animation, ajax, etc. very easy.In this tutorial, we will learn to add the previous set of elements on the stack to the current set. jQuery maintains an internal stack of the changes that are performed to the matched stack. When the DOM traversal functions or methods are called, the new elements are pushed into the stack. So to use previous stack elements, the addBack() method is called.SyntaxWe ... Read More

How to return a passed string with letters in alphabetical order in JavaScript?

Imran Alam
Updated on 01-Jul-2022 13:42:27

2K+ Views

We could apply String split(), Array sort() and Array join() methods to write a function that returns a passed string with letters in alphabetical order in JavaScript. A JavaScript function is a block of code that is executed when it is invoked. A string is a sequence of characters. In JavaScript, strings are represented by the type String.Input string : tutorialspoint Output string: aiilnooprstttuStepsSplit the string into an array of characters using split() method.Apply the sort() method to sort the characters in alphabetical order.Finally, we use the join() method to join the characters back into a string.The Array.sort() method sorts the ... Read More

How to convert array of strings to array of numbers in JavaScript?

Imran Alam
Updated on 15-Sep-2023 02:14:31

27K+ Views

In JavaScript, there are different ways to convert an array of strings to an array of numbers. The first way is to use the built-in parseInt() method, and the second way is to use a type conversion function, and the third one is to use the unary + operator.Using the parseInt() methodThe parseInt() method is a built-in function in JavaScript that takes a string as an argument and returns a number. This method can be used to convert an array of strings to an array of numbers.SyntaxThe syntax of the parseInt() method is as follows −parseInt(string, radix);ParametersString − The string ... Read More

What is difference between unescape() and escape() functions in JavaScript?

Imran Alam
Updated on 01-Jul-2022 13:08:25

2K+ Views

JavaScript provides two functions for dealing with encoded strings: escape() and unescape(). The escape() function is used to encode a string, making it safe for use in a URL. The unescape() function is used to decode an encoded string.The differencesThe main difference between the two functions is that escape() encodes characters that are not ASCII, while unescape() only decodes those characters. This means that if you use escape() on a string that only contains ASCII characters, the result will be the same as the input string. However, if you use unescape() on a string that contains non-ASCII characters, the result ... Read More

What is the difference between undefined and not defined in JavaScript?

Imran Alam
Updated on 01-Jul-2022 13:04:34

6K+ Views

In JavaScript, there are two main ways that a variable can be "undefined". The first is when you declare a variable without giving it a value. The second is when you try to access a variable that does not exist.Undefined in JavaScript When a variable is declared without a value, it is automatically given the value of "undefined". This can happen if you forget to assign a value to a variable, or if you intentionally do not assign a value (For example, if you are waiting for user input).If you try to access a variable that does not exist, you will ... Read More

Advertisements