1
我想,當我點擊一個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!');
}
});
}
}
});
});
但我收到此錯誤:
Uncaught TypeError: Illegal invocation
我我不確定問題出在哪裏。我查了幾次jQuery UI對話框和jQuery $ .ajax文檔,我的代碼似乎是正確的。
任何想法?