Skip to content

Instantly share code, notes, and snippets.

@henideepak
Last active October 18, 2022 09:05
Show Gist options
  • Save henideepak/c0eaece2e2dcfe2f6d7fa66a15989c2e to your computer and use it in GitHub Desktop.
Save henideepak/c0eaece2e2dcfe2f6d7fa66a15989c2e to your computer and use it in GitHub Desktop.
Ajax Response syntax
$.ajax() jquery function
Jquery ajax method takes following arguments:
a url to make a call
a method name
a response type
form data to send
Following is full syntax used for ajax method:
$.ajax({
url: "http://www.phpcodebooster.com/sample/url",
method: "POST|GET|PUT|DELETE", // The HTTP method to use for the request
dataType: "xml|json|script|html", // The type of data that you're exerciseecting back
data: { // Data to be sent to the server.
key1: value1,
key2: value2
},
error: function() {
// A function to be called if the request fails.
},
beforeSend: function() {
// A function to be called if before the request is made.
},
success: function(response) {
// A function to be called if the request succeeds.
},
complete: function(response) {
// A function to be called when the request finishes
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment