send data in ajax code example
Example 1: ajax data post call in javascript
$.ajax({
url: 'ajaxfile.php',
type: 'post',
data: {name:'yogesh',salary: 35000,email: '[email protected]'},
success: function(response){
}
});
Example 2: how to send data using ajax
$.ajax({
url: "/something",
type: "GET",
data: {p1: "This is our data"},
success: function(data){
console.log(data);
}
}).done(function(){
console.log("Success.");
}).fail(function(){
console.log("An error has occurred.");
}).always(function(){
console.log("Complete.");
});
Example 3: $.post javascript
$.post(
"path/to/your/php/file",
{
param1: "Value",
param2: "Value"
},
function(data) {
}
);