-9

I have seen different types of jQuery AJAX call with type:'GET' and type:'POST' with PHP Mysqli Programming but i have doubt :-

So when and Where we used these two different type , i mean in which scenario we are use type:'GET' and type:'POST' with PHP Mysqli like these:-

Is there any technical difference between both of them?

type:"GET"

$.ajax({
    type:"GET",
    url:"action.php",
    data:{key:val},
    success:function(data){
        alert(data);
   }
});

type:"POST"

$.ajax({
    type:"POST",
    url:"action.php",
    data:{key:val},
    success:function(data){
        alert(data);
   }
});
KUMAR
  • 1,993
  • 2
  • 9
  • 26
  • who has down vote my question , what is the problem in that? – KUMAR Jul 14 '20 at 12:19
  • https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods – Andreas Jul 14 '20 at 12:19
  • 1
    @KUMAR, problem is that's very simple question, and in first step, you should use Google. FYI: that wasn't me who downvoated. – biesior Jul 14 '20 at 12:21
  • @biesior ok sir , i am not asking its you but i have confused in that. i want to know the answer properly with ajax jquery php call. – KUMAR Jul 14 '20 at 12:23

1 Answers1

0

There's a lot of information about GET vs POST request, as it's one of the oldest topics on the internet: https://www.w3schools.com/tags/ref_httpmethods.asp

In general, for security reasons, it's always better to use POST over the GET.

In AJAX requests difference is the same.

Use Inspector in your browser and navigate to Network tab, to validate that:

Screenshot for AJAX request in Network inspection

biesior
  • 55,576
  • 10
  • 125
  • 182