ELEVATE YOUR BUSINESS WITH

Limitless customization options & Elementor compatibility let anyone create a beautiful website with Valiance.

Get And Post in Jquery

SELECT * FROM `itio_tutorial_master` WHERE `tutorial_menu`='12' AND `tutorial_submenu`='713' AND `tutorial_status`=1 LIMIT 1

Get And Post in Jquery

In jQuery, GET and POST are two commonly used AJAX methods to request or send data to a server without reloading the page.

They are used for:

  • GET: Requesting data from a server.

  • POST: Sending data to a server (like form submission).


? 1. $.get() – HTTP GET Request

? Syntax:

javascript

$.<button "#loadUser").click(function () { $.get("user.php", { id: 1 }, function (data) { $("#userInfo").html(data); }); });</script>

This sends GET user.php?id=1, and displays the response inside the #userInfo div.


? 2. $.post() – HTTP POST Request

? Syntax:

javascript

$.<form "#myForm").submit(function (e) { e.preventDefault(); // Prevent default form submission $.post("submit.php", $(this).serialize(), function (data) { $("#response").html(data); }); });</script>

This submits form data via POST to submit.php and shows the server response in the #response div.


? Difference Between .get() and .post()

Feature.get().post()
PurposeFetch dataSend data
Data visible?Yes, in URLNo, hidden in request body
Max size?LimitedNo strict limit
Use casesLoading content, getting dataForm submission, saving/updating data


? Pro Tip: Using .done() for Better Structure

javascript

$.post("submit.php", {name: "Jane"}) .done(function(response) { console.log("Success:", response); }) .fail(function(error) { console.log("Error:", error); });


Want to try $.ajax() for more control?

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql