我有以下代码:在里面我放了 2alert()
进行调试。为什么 alert2 在 alert1 之前显示???
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$.ajax({
type: "POST",
url: "ManagerBaseKit.aspx/GetDummyVersions",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
var items = [];
$.each(result.d.Version, function (key, val) {
items.push('<li id="' + key + '">' + val + '</li>');
});
$('<ol/>', {
'id': 'selectable',
html: items.join('')
}).appendTo('.baseVersionsTest');
alert('1'); // should be alerted 1st
}
});
alert('2'); // should be alerted 2nd
});
</script>
编辑:我怎样才能让$.ajax
被称为第一件事?