In this article we will show the solution of jQuery ajax post data example, a POST method, however, does not cache data, and it is often used to send data along with a request.
A POST HTTP request is used to load a page from the server using jQuery.post( url, [data], [callback], [type]). XMLHttpRequest is the object returned by the method.
An URL string can be used to represent the URL of the request. The data parameter represents key/value pairs or the return value from the function called serialize().
An optional argument denotes a function that should be performed in the event that data loading is successful.
It represents the type of data returned to the callback function: "xml", "html", "script", "json", "jsonp", or "text".
Step By Step Guide On jQuery Ajax Post Data Example :-
<html>
<head>
<title>TalkersCode jQuery Example</title>
<script type = "text/javascript"
src = "https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js">
</script>
<script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$("#driver").click(function(event){
$.post(
"result.php",
{ name: "Maggi" },
function(data) {
$('#stage').html(data);
}
);
});
});
</script>
</head>
<body>
<p>TalkersCode</p>
<div id = "stage" style = "background-color:cc0;">
TalkersCode
</div>
<input type = "button" id = "driver" value = "Load Data" />
</body>
</html>
- Our first step is to write <HTML>, which tells the browser what version of HTML we're using. HTML documents contain tags as their first element.
- The project's heading must be described using the head> tag. Titles and final brackets differ from final brackets because they are both open, rather than closed.
- The <script> tag was then added. The script tag also includes the javascript google API run or an explanation of the code or file we used.
- The script is then closed and head closed.
- Then again we open the <script> tag and then add. The script tag also includes the javascript google API run or an explanation of the code or file we used.
- The <body> tag follows, which describes the content of the webpage.
- Our next step is to create a paragraph and then to set the color for the background.
- Then we create a button.
- After that we closed program using </body></html>
Conclusion :-
The GET and POST methods are the most common request-response methods between a client and server.
Data is requested from a specified resource using the GET method.
PUSH - Sends data to be processed to a specified resource, Data can be obtained from a server using GET (get-retrieve). Data may be cached when using the GET method.
I hope this article on jQuery ajax post data example helps you and the steps and method mentioned above are easy to follow and implement.














