Да, не думайте, что это диалоговое окно, в котором можно использовать данные json. Сделайте это:
- стреляй в свой Аякс
- в вашем обработчике подготовить и открыть диалог
- в обработчике кнопок для диалогового окна, если хотите, запустите еще ajax, а затем обработайте результаты.
Ключ в том, чтобы думать о диалоге иначе, чем примеры, которые вы видите на веб-сайте jQuery UI. Заполните диалог динамически, просматривая возвращаемые значения JSON и используя селекторы jQuery, чтобы найти то, что вам нужно, создать больше и вставить новые элементы в содержимое диалога.
Вот более конкретный пример:
$( "#dialog" ).dialog({
modal: true,
buttons: {
Ok: function() {
fire_ok_ajax_with_handler(); //pretend the handler is ok_handler
}
}
});
// this method is called when the action the user takes wants to
// open the dialog. Note that it doesn't actually open the dialog
// but instead starts the ajax process of getting the data it needs
// to prepare the dialog
$( "#opener" ).click(function() {
$( "#dialog" ).dialog( "open" );
fire_ajax_to_start_stuff();
return false;
});
function fire_ajax_to_start_stuff(...) {
// assume start_handler method
}
function start_handler(data) {
//process data, which can be json if your controller formats it that way
// use the data to dynamically setup the dialog,
// show the dialog
$( "#dialog" ).dialog( "open" );
}
function fire_ok_ajax_with_handler() {
// this is where you set up the ajax request for the OK button
}
function ok_handler(data) {
// handle possible errors messages
// close the dialog
$( this ).dialog( "close" );
}
Обратите внимание, что в этом примере МНОГО псевдокода / размахивания руками, но он должен дать вам базовый подход.