0
$.ajax({
                type: "POST",
                url: "Services/Services.asmx/GetAllDoctors",
                data: "{}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    for (var i = 0; i < data.d.length; i++) {
                        var centerAddress = CreateAddressToBind(data.d[i]);
                        doctorTemplates[i] = { row_ID: data.d[i].row_ID, DOCTOR_ID: data.d[i].DOCTOR_ID, DOCTOR_NAME: data.d[i].DOCTOR_NAME, LINE1_BLDG: data.d[i].LINE1_BLDG, LINE2_STREET: data.d[i].LINE2_STREET, LINE3_AREA: data.d[i].LINE3_AREA, CITY: data.d[i].CITY, PINCODE: data.d[i].PINCODE, MEDICALCENTER_ADDRESS: data.d[i].MEDICALCENTER_ADDRESS, STATE: data.d[i].PINCODE, OTHER_DETAILS: data.d[i].OTHER_DETAILS, CONTACT_DETAILS: data.d[i].CONTACT_DETAILS, modified: 0 }
                        $("#doctorTable").append("<tr id='tableRow'><td id='rowid' class='hiddenColumn'>" + data.d[i].row_ID.toString() + "</td><td id='doctorid'>" + data.d[i].DOCTOR_ID.toString() + "</td><td id='doctorname'>" + data.d[i].DOCTOR_NAME.toString() + "</td><td id='centerAddress'>" + data.d[i].MEDICALCENTER_ADDRESS.toString() + "</td><td id='doctorAddress'>" + data.d[i].LINE1_BLDG.toString() + "," + data.d[i].LINE2_STREET.toString() + "," + data.d[i].LINE3_AREA.toString() + "," + data.d[i].CITY.toString() + "," + data.d[i].PINCODE.toString() + "," + data.d[i].STATE.toString() + "</td><td id='cdetails'>" + data.d[i].CONTACT_DETAILS.toString() + "</td><td id='odetails'>" + data.d[i].OTHER_DETAILS.toString() + "</td><td><a href='#' onclick='EditRecord(this)'>Edit</a></td><td><a href='#' onclick='DeleteRecord(this)'>Delete</a></td><td class='modified'>0</td></tr>");
                    }
                    $("#doctorTable").dataTable();
                }
            });

如何在加载内容时显示 ajax 状态消息加载?

4

2 回答 2

1

只需在发送请求之前在您要更新的选择器中提供一些 html 消息。像这样

$("#doctorTable").text("loading");
$.ajax(....);
于 2012-04-11T11:31:16.810 回答
1

尝试:


$('#doctorTable')
    .hide()  // hide it initially
    .ajaxStart(function() {
        $(this).show();
    })
    .ajaxStop(function() {
        $(this).hide();
    });
于 2012-04-11T11:33:29.463 回答