-
Performing POST Request with AJAX using jQuery
POST requests are identical to GET requests in jQuery. So, generally which method you should use either $.get() or $.post() is basically depends on the requirements of your server-side code. If you have large amount of data to be transmitted (e.g. form data) you need to use POST, because GET has a stringent limit on the data transfer. Example…
-
Performing GET Request with AJAX using jQuery
The following example uses the jQuery $.get() method to make an Ajax request to the “date-time.php” file using HTTP GET method. It simply retrieves the date and time returned from the server and displays it in the browser without refreshing the page. Example Here’s our “date-time.php” file that simply output the current date and time of the…
-
jQuery Ajax GET and POST Requests
jQuery $.get() and $.post() Methods The jQuery’s $.get() and $.post() methods provide simple tools to send and retrieve data asynchronously from a web server. Both the methods are pretty much identical, apart from one major difference — the $.get() makes Ajax requests using the HTTP GET method, whereas the $.post() makes Ajax requests using the HTTP POST method. The basic syntax of these methods can be given with: $.get(URL, data, success); —Or— $.post(URL, data, success);…
-
jQuery Ajax Load
jQuery load() Method The jQuery load() method loads data from the server and place the returned HTML into the selected element. This method provides a simple way to load data asynchronous from a web server. The basic syntax of this method can be given with: $(selector).load(URL, data, complete); The parameters of the load() method has the following meaning: Let’s put this method into…
-
jQuery Ajax
What is Ajax Ajax stands for Asynchronous Javascript And Xml. Ajax is just a means of loading data from the server to the web browser without reloading the whole page. Basically, what Ajax does is make use of the JavaScript-based XMLHttpRequest object to send and receive information to and from a web server asynchronously, in the background, without interfering…
-
jQuery filter() Method
The jQuery filter() method can take the selector or a function as its argument to filters the set of matched elements based on a specific criteria. The supplied selector or function to the filter() method is tested against each element in the set of matched elements and all the elements that matching the supplied selector or pass the function’s test will…
-
jQuery Filtering
Filtering the Elements Selection jQuery provides several methods such as filter(), first(), last(), eq(), slice(), has(), not(), etc. that you can use to narrow down the search for elements in a DOM tree. jQuery first() Method The jQuery first() method filters the set of matched elements and returns the first element from the set. The following example will only highlight the first <li> element within the <ul> element by adding…
-
jQuery nextUntil() Method
The jQuery nextUntil() method is used to get all the following siblings up to but not including the element matched by the selector. In simple words we can say it returns all the next siblings elements between two given elements in a DOM hierarchy. The following example will highlight all the following sibling elements of the <h1> element excluding…
-
jQuery Traversing Siblings
Traversing Sideways in DOM Tree In logical relationships siblings are those elements that share the same parent. jQuery provides several methods such as siblings(), next(), nextAll(), nextUntil(), prev(), prevAll() and prevUntil() that you can use to traverse sideways in the DOM tree. jQuery siblings() Method The jQuery siblings() method is used to get the sibling elements of the selected element. The following example will highlight the siblings of…
-
jQuery find() Method
The jQuery find() method is used to get the descendant elements of the selected element. The find() and children() methods are similar, except that the find() method search through multiple levels down the DOM tree to the last descendant, whereas the children() method only search a single level down the DOM tree. The following example will add a border around all the <li> elements that are descendants…
