0
我試圖發送值的日期代碼背後使用ajax調用,但它返回。 我在做什麼錯在這裏AJAX調用返回'undefined'
function FetchTime() {
debugger;
var Pt_AppDate = document.getElementById("appdate").value;
var reqs ='{AppointmentDate: "' + Pt_AppDate + '"}';
$.ajax({
type: "POST",
url: "AppointmentForm.aspx/FetchATime",
data: reqs,
async: false,
contentType: "application/json; charset=utf-8",
datatype: "json",
success: OnSuccessApptwo,
failure: function (response) { alert(response.d); },
error: function (response) { alert(response.d); }
});
}
代碼隱藏
public void FetchATime()
{
conn.ConnectionString = dbObj.connString;
conn.Open();
string query2 = "Select Appointment_time from Appointments where convert(date, Appointment_date) < '" + AppointmentDate + "'";
SqlCommand cmd2 = new SqlCommand(query2, conn);
AvailableTime.DataSource = cmd2.ExecuteReader();
AvailableTime.DataTextField = "Appointment_time";
DoctorName.DataValueField = "Symptom_id";
AvailableTime.DataBind();
AvailableTime.Items.Insert(0, new ListItem("--Select Available Time", "0"));
conn.Close();
}