jquery GET and POST confusion

Posted by JPro on Stack Overflow See other posts from Stack Overflow or by JPro
Published on 2010-04-06T16:40:00Z Indexed on 2010/04/06 16:43 UTC
Read the original article Hit count: 420

Filed under:
|

Hi,

I am not quiet sure how jquery works. I want to know few things about the GET and POST in terms of jQuery.

I use the following code in my app :

<script>
function example_ajax_request() {
  $('#example-placeholder').html('<p>Loading results ... <img src="ajax-loader.gif"  /></p>');
  $('#example-placeholder').load("ind.php?show=" + $('#box option:selected').val());
}
</script>

I am not using either GET or POST in this method. I am using a button to call the example_ajax_request to process the request and get the results.

Sometimes I see code like this:

$.ajax({
  url: 'loader.php',
  data: 'somedata',
  method: 'GET',
  success: function(data){
    $('#er').text(data);
  }
});

My doubt is, is it required or not that we use a method to post the data? (either GET or POST) while send and getting the data in PHP webapps? The code that I use first works fine even though I do not use any POST or GET methods.

Any inputs?

Thanks.

© Stack Overflow or respective owner

Related posts about php

Related posts about ajay