【发布时间】:2014-11-09 02:16:58
【问题描述】:
简单的问题, 我知道 ajax 是异步的,我有以下功能正在处理响应警报,正在工作但是,我的问题是我想知道如何将 ajax 响应的结果存储在模式的 var 中以及其他文本按下按钮以显示模态时显示..我尝试过 async:false 但它不起作用.. :( 这是我的功能
getVersion: function() {
$.ajax({
dataType: 'json',
type: 'GET',
url: this.options.url.generalsUrl + '/getAppVersion',
cache: false,
async: false,
success: function(response) {
alert(response.VERSION);//ok this is for testing
},
error: function(jqXHR, exception) {
alert("There was an error retrieving the version of the application.");
}
});
},
但是在模态按钮功能的其他地方,我想将它粘贴在 var 内容的其他文本中,这是另一个没有显示的功能,因为我不想偷懒..
var imgAbout = $('#topright-menu ul.menu-divmenu > li > a > img[src$="about.png"]');
imgAbout.click(function(e) {
e.preventDefault();
var modal = (self.modal());
var content = $('self.getVersion()') + //this line is bad how can i show the response?
"in the following browsers have been tested: <br>" +
'<img src="images/ie.png" width="45" height="45"/>Internet Explorer 11.0.9600.17239<br>' +
'<img src="images/mozilla.png" width="45" height="45"/>Mozilla Firefox 32.0<br>' +
'<img src="images/chrome.png" width="45" height="45"/>Google Chrome 37.0.2062.103 m<br>';
var $div_container = $('<div></div>')
.addClass('jtable-main-container');
var $div_title = $('<div></div>').addClass('jtable-title')
.appendTo($div_container);
$('<div></div>').addClass('jtable-title-text')
.text('Information for the application')
.appendTo($div_title);
var $table = $('<table></table>').appendTo($div_container);
var $row = $('<tr></tr>').appendTo($table);
var $cell = $('<td></td>').html(content).appendTo($row);
$('#jsn-pos-left').hide();
modal.open({
content: $div_container
});
});
有什么帮助吗?我相信这是一件容易的事,但对我来说很难.. :(
【问题讨论】: