jquery ajax request
snippet in javascript

jquery ajax request

user8325

$.ajax('/jquery/submitData', {
    type: 'POST',  // http method
    data: { myData: 'This is my data.' },  // data to submit
    success: function (data, status, xhr) {
        $('p').append('status: ' + status + ', data: ' + data);
    },
    error: function (jqXhr, textStatus, errorMessage) {
            $('p').append('Error' + errorMessage);
    }
});

jquery ajax

user6155

var formdata = new FormData();
formdata.append("post_name","value");
$.ajax({
  type: "POST",
  url: "file.php",
  data: formdata,
  contentType: false,
  processData: false,
  success: function (response) {
  	console.log(response);
  }
});

make ajax request post jquery

user4392

$.ajax({
  method: "POST",
  url: "some.php",
  data: { name: "John", location: "Boston" }
})

ajax syntax in javascript

user7940

var id = empid;

$.ajax({
    type: "POST",
    url: "../Webservices/EmployeeService.asmx/GetEmployeeOrders",
    data: "{empid: " + empid + "}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(result){
        alert(result.d);
        console.log(result);
    }
});

jquery ajax

user3216

 $.ajax({

   url     : "file.php",
   method  : "POST",

       data: { 

         //key                      :   value 
         action                   	:   action , 
         key_1   					:   value_key_1,
         key_2   					:   value_key_2
       }
   })

   .fail(function() { return false; })

	// Appel OK
   .done(function(data) {

   console.log(data);

 });