1$.ajax({
2 url:'your url',
3 type: 'POST', // http method
4 data: { myData: 'This is my data.' }, // data to submit
5 success: function (data, status, xhr) { // after success your get data
6 $('p').append('status: ' + status + ', data: ' + data);
7 },
8 error: function (jqXhr, textStatus, errorMessage) { // if any error come then
9 $('p').append('Error' + errorMessage);
10 }
11});
1var id = empid;
2
3$.ajax({
4 type: "POST",
5 url: "../Webservices/EmployeeService.asmx/GetEmployeeOrders",
6 data: "{empid: " + empid + "}",
7 contentType: "application/json; charset=utf-8",
8 dataType: "json",
9 success: function(result){
10 alert(result.d);
11 console.log(result);
12 }
13});
14
1 $.ajax({
2
3 url : "file.php",
4 method : "POST",
5
6 data: {
7 //key : value
8 action : action ,
9 key_1 : value_key_1,
10 key_2 : value_key_2
11 }
12 })
13
14 .fail(function() { return false; })
15 // Appel OK
16 .done(function(data) {
17
18 console.log(data);
19
20 });
1// Using the core $.ajax() method
2$.ajax({
3
4 // The URL for the request
5 url: "post.php",
6
7 // The data to send (will be converted to a query string)
8 data: {
9 id: 123
10 },
11
12 // Whether this is a POST or GET request
13 type: "GET",
14
15 // The type of data we expect back
16 dataType : "json",
17})
18 // Code to run if the request succeeds (is done);
19 // The response is passed to the function
20 .done(function( json ) {
21 $( "<h1>" ).text( json.title ).appendTo( "body" );
22 $( "<div class=\"content\">").html( json.html ).appendTo( "body" );
23 })
24 // Code to run if the request fails; the raw request and
25 // status codes are passed to the function
26 .fail(function( xhr, status, errorThrown ) {
27 alert( "Sorry, there was a problem!" );
28 console.log( "Error: " + errorThrown );
29 console.log( "Status: " + status );
30 console.dir( xhr );
31 })
32 // Code to run regardless of success or failure;
33 .always(function( xhr, status ) {
34 alert( "The request is complete!" );
35 });
36