【发布时间】:2018-02-07 14:40:36
【问题描述】:
我正在尝试显示一些存储在 JSON 对象中的虚拟数据。我是这个主题的新手。所以我不清楚如何进行。
但是我写了一个 javascript 函数和 ajax 调用。
$(document).ready(function () {
var data = {
"id": 1,
"schedule": 1,
"channel": "AXN",
"fromDate": "2018-01-19",
"toDate": "2018-01-31",
"startTime": "11:00:00",
"endTime": "12:00:00",
"type": "TVC",
"mediaFile": 1
}
$.ajax({
type: "POST",
url: URI.customSchedule.getCustomScheduleUrl(),
data: data,
beforeSend: function () {
},
processData: false,
contentType: false,
cache: false,
timeout: 600000,
success: function (data) {
data.channel = $('#selectChannel').val();
data.fromDate = $('#fromDate').val();
date.toDate = $('#toDate').val();
date.startTime = $('#startTime').val();
date.endTime = $('#endTime');
},
error: function (e) {
}
});
});
这是将 JSON 对象中的数据分配给 html 字段的方式,这不起作用。
data.channel = $('#selectChannel').val();
data.fromDate = $('#fromDate').val();
date.toDate = $('#toDate').val();
date.startTime = $('#startTime').val();
date.endTime = $('#endTime');
有人可以帮我解决这个问题并解释我所犯的错误吗?请帮我在 html 字段中显示存储在 JSON 对象中的值。
编辑:
当我调试代码时,调试点并没有进入 Ajax 调用内部。这里的问题是什么?
【问题讨论】:
-
你可以在成功函数中记录数据,在错误函数中记录错误,看看会发生什么
标签: javascript jquery json ajax html