我有这样一个功能:uiModal.simpleModal('<p>This is some content</p>');
负载在通过HTML使用jQuery AJAX
这应该叫模态与传递的数据为模式的内容。例如(注意我没有添加modalHtml,因为它与这个问题无关)。
simpleModal: function (data) {
var responseHtml = data;
// Append the modal HTML to the DOM
var modalInstance = $('body').append(modalHtml);
// Dynamically load in the passed data from the call
$.ajax({
timeout: 5000,
success: function (responseHtml) {
$(modalInstance).find('.uiModalContent').html($(responseHtml));
$(modalInstance).find('.uiModalContent').removeClass('loading');
isModalSuccess = true;
},
error: function() {
$(modalInstance).find('.uiModalContent').html('<div class="message error"><h2>Unknown Error</h2> Please contact support</p></div>');
$(modalInstance).find('.uiModalContent').removeClass('loading');
}
});
$(modalInstance).find('.ModalClose').live('click', function (e) {
e.preventDefault();
$(this).parents('.uiModal').fadeOut(function() { $(this).parents('.uiModalWrapper').remove() });
});
},
但是它不会加载数据!有人能指出我在正确的方向
感谢
没有URL,正在函数调用中传递的内容 – Cameron
不是。 ajax方法用于从URL中获取数据。你这样做是错误的。忘掉ajax部分,在这种情况下你不需要它。 –