Home » jQuery Ajax GET & POST REQUEST Methods PHP MySQLi

jQuery Ajax GET & POST REQUEST Methods PHP MySQLi

jQuery Ajax GET & POST REQUEST Methods PHP MySQLi

Today, We want to share with you jQuery Ajax GET & POST REQUEST Methods PHP MySQLi.
In this post we will show you jQuery – GET & POST REQUEST Methods with PHP, hear for Jquery, Ajax Form Submit with PHP,Mysql we will give you demo and example for implement.
In this post, we will learn about Ajax Add & Delete MySQLi records using jQuery & PHP with an example.

There are as a below HTTP Request: GET vs. POST

There are main Two types of Browsers user(Client) can Send An data information to The WebSite(SERVER).

The use of GET METHOD
The use of POST METHOD

The use of Specially Get Method Seprated by ? parameters.

Get Method Send Data restiction to send data client side to server side (1024 characters) Only.

Read Also:  jQuery AJAX Submit form serialize PHP MySQLi

This Fet method Featch all of this data $_GET or as a particuler varible fetch usinf GET Method ($_GET[‘varible_name’]).

The POST method (Send c to s)transfers ALL information via HTTP headers.(cros)

The POST Method never have a any type of Restriction and data information Send to Client Side to Server Side(website).

POST Method send Data Client Side to webserver send used to ASCII as well as binary data.
The POST Method Provides Fetch The All Of The Data Information($_POST) or As a Varible Fetch the data ($_POST[‘varible_name’]).

By using Stntax :

$_SERVER['REQUEST_METHOD']

Example : Detecting request type in PHP (GET, POST, PUT or DELETE)

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
     // request is using the POST method
}
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
     // Show The request is using the GET method
	 
}	
if ($_SERVER['REQUEST_METHOD'] === 'PUT') {
     // Show The request is using the PUT method
	 //   Example of Put method data send client to server <input placeholder="Put Method Enter data"type="hidden" name'_METHOD'id="put_method" value="PUT">
}
if ($_SERVER['REQUEST_METHOD'] === 'DELETE') {
     // Show The request is using the DELETE method
	 //    <input id="delete_method" type="hidden" placeholder="enter data id or data id" name'_METHOD' value="DELETE">
}

Two HTTP Request Methods: GET and POST

The Example Of GET Method

<?php
   if( $_GET["p_name"] || $_GET["tech_type"] ) {
      echo "Selected Project is ". $_GET['name']. "very useful,
";
      echo "You are using  ". $_GET['tech_type']. " Technology.It's very easy to understand";
      
      exit();
   }
?>
<html>
   <body>
   

<form id="FetchData" action = "<?php $_PHP_SELF ?>" name="methodusingfetchdata" method = "GET">
         Prohect Name: <input type = "text" placeholder="" name = "p_name" id="pro_name"/>
         Technology Type: <input type = "text" placeholder="Technology Type" id="tech_id" name = "tech_type" />
         <input type = "submit" />
      </form>

      
   </body>
</html>


The Example Of POST Method

<?php
   if( $_POST["projecttitle_name"] || $_POST["tech_type"] ) {
      echo "Selected Project is ". $_POST['name']. "very useful,
";
      echo "USING POST Method You are using  ". $_POST['tech_type']. " Technology.It's very easy to understand";
      
      exit();
   }
?>
<html>
   <body>
   

<form id="FetchData" action = "<?php $_PHP_SELF ?>" name="methodusingfetchdata" method = "POST">
         Prohect Name: <input type = "text" placeholder="Enter Project Titel headding" name = "projecttitle_name" id="pro_name"/>
         Technology Type Enter : <input type = "text" placeholder="Technology Type" id="tech_id" name = "tech_type" />
         <input value="Press(Click This button)" name="Project_submit" type = "submit" />
      </form>

      
   </body>
</html>

$.ajax({
	type: "POST",
	contentType: "application/json; charset=utf-8",
	url: "api/request_project.php",
	dataType: "json",
	//Send data using 
	data: "{'projectStartDate' : '" + new Date(projectstartdate) + "','projectEndDate' : '" + new Date(.projectenddate) + "','projectNo' : '" + $data['projectNo'] + "','StatusCode' : '" + StatusCode + "'}",
	
	success: function (data) {
		var msg = $data['Name'] + "added Successfully.";
		window.setTimeout(function () {
			window.location.href = "projectAssign.php";
		}, 0000);
	},
	error: function (result) {
		alert("function in Generated err display...");
	}
});


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Vue.js DatePicker Source Code Example with Demo
  2. Read Also:  NodeJS RESTful API User Authentication with AngularJS using PHP MYSQL
  3. Read Also:  PHP MySQL: Querying fetch Data from Database
  4. Read Also:  VueJS Force download GET request using axios
  5. Read Also:  jQuery mouseover() Events Examples (jquery mouseover event)
  6. Read Also:  jquery ajax dropdown onchange example in php MySQL Database
  7. Read Also:  Dynemically HTML table from AJAX response using PHP
  8. Read Also:  Simple Jquery ajax request example with demo
  9. Read Also:  PHP Shorten String Function
  10. Read Also:  PHP Ajax Display Dynamic MySQL Data in Bootstrap Modal

Leave a Comment

Your email address will not be published. Required fields are marked *