HI i have used both the things in my experience i was thinking method and type both are POST and GET methods.
But seems like they are not similar.?
if i use type
it is working i am serializeing
a form data..
if i write method
it is not working can can anyone explain what is the diff between them..?
$.ajax({ url: "controller.php", type: 'POST', method: "POST", dataType: "json", });
help is appropriated.
$.ajax({name:value, name:value, ... }) Parameters: The list of possible values are given below: type: It is used to specify the type of request. url: It is used to specify the URL to send the request to.
The ajax() method is used to perform an AJAX (asynchronous HTTP) request. All jQuery AJAX methods use the ajax() method. This method is mostly used for requests where the other methods cannot be used.
From https://api.jquery.com/jQuery.ajax/ you see that contentType is to tell what you send while dataType is what you would like as a response (and the response includes a content-type as well so that you can check what is actually sent back).
GET is basically used for just getting (retrieving) some data from the server. Note: The GET method may return cached data. POST can also be used to get some data from the server. However, the POST method NEVER caches data, and is often used to send data along with the request.
type (default: 'GET') Type: String An alias for method. You should use type if you're using versions of jQuery prior to 1.9.0.
http://api.jquery.com/jquery.ajax/
From: http://api.jquery.com/jquery.ajax/
method:
The HTTP method to use for the request (e.g. "POST", "GET", "PUT"). (version added: 1.9.0)
type:
An alias for method. You should use type if you're using versions of jQuery prior to 1.9.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With