JQuery Ajax Snippet

JQuery Ajax Snippet

Consider to think about.
Review the code below.

Syntax

[code]$.ajax({
type: 'POST',
url: url,
data: data,
success: success,
dataType: dataType
});[/code]

Example

[code]$.ajax({
type: "POST",
url: document.URL + '/PageList',
data: "{}",
async: false,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
var pages = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;

$('#locPage' + locId).find('option').remove();

$.each(pages, function () {
$('#locPage' + locId).append(
$('<option></option>').val(this.PageId).html(this.Name)
);
});
}
});[/code]