【发布时间】:2017-11-03 20:13:58
【问题描述】:
当我单击 jQuery UI 对话框 Save 按钮时,我正在尝试发送 AJAX 请求,我就是这样做的:
$(function () {
var comment_dlg = $('#add_comment_dialog');
var quote_id = $('#comment_quote_id');
$('#order_push').click(function () {
quote_id.val($(this).data('id'));
comment_dlg.dialog('open');
});
comment_dlg.dialog({
title: "Write a comment",
autoOpen: false,
modal: true,
width: 600,
height: 300,
buttons: {
Cancel: function () {
$(this).dialog('close');
},
'Save': function () {
$.ajax({
url: Routing.generate('push_order_xml'),
method: 'GET',
data: { quote_id: quote_id },
cache: false
}).done(function (data, textStatus, jqXHR) {
if (data.success.length) {
alert(data.success);
} else {
alert('Something went wrong!');
}
});
}
}
});
});
但我收到此错误:
未捕获的类型错误:非法调用
我不确定问题出在哪里。我已经检查了 jQuery UI Dialog 和 jQuery $.ajax 文档几次,我的代码似乎是正确的。
有什么想法吗?
【问题讨论】:
标签: javascript jquery jquery-ui jquery-ui-dialog