【发布时间】:2015-04-12 20:23:44
【问题描述】:
我正在使用 x-editable,想知道如何使用 jquery 和 ajax 填充我的选择元素。
[编辑 - 为清楚起见]
这是我的代码:
jQuery(document).ready(function() {
//toggle `popup` / `inline` mode
$.fn.editable.defaults.mode = 'popup';
var getSource = function() {
var url = "/api/rpc/payments/status_options";
$.ajax({
type: 'GET',
async: true,
url: url,
dataType: "json",
success: function(responseObject){
}
});
};
//make status editable
$('.payments-click').editable({
type: 'select',
title: 'Select status',
placement: 'right',
value: 2,
source: getSource()
/*
//uncomment these lines to send data on server
,pk: 1
,url: '/post'
*/
});
});
我正在尝试获取来源:
source: getSource()
来自函数,但不是 100% 确定如何从 Ajax 调用返回数据。
【问题讨论】:
标签: javascript jquery ajax twitter-bootstrap x-editable