json and ajax code example

Example 1: jquery ajax json

$.ajax({
  method: "POST",
  url: "some.php",
  dataType: "json",
  data: {}
}).done(json => console.log(json));

Example 2: jquery ajax type json

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