我的问题是当我发表评论"返回maxID;"我得到了我拥有的ID数组的结果(例如1 2 3 4 5)但是如果我尝试返回maxID,结果是1而不是5.为什么?怎么解决? 这是我的代码:
Sub RunFile()
Call ExecuteShell("C:\", "LAPBTN1749", "filename.sql")
End Sub
Sub ExecuteShell(path As String, hostname As String, file As String)
Dim retval
retval = Shell("SQLCMD -E -S " & Chr$(34) & hostname & "\SQLEXPRESS" & Chr$(34) & " -i " _
& Chr$(34) & path & file & Chr$(34), vbMinimizedFocus)
End Sub
答案 0 :(得分:0)
return
太早了,它在循环中,你在第一行之后留下success
。
基本上return
在ajax-callback中无用,只需在maxID
的末尾打印success
。
修正$.ajax
- 致电:
// Send the JSONP request using jQuery $.ajax({ url: url.join(''), dataType: 'jsonp', success: function(data) { var rows = data['rows']; maxID = 0; //don't use for-in-loops to iterate over arrays //for (var i in rows) {for (var i = 0; i < rows.length; ++i) { var rec = rows[i][0]; var collection = rows[i][1]; var idValue = parseInt(collection); if (idValue > maxID){maxID = idValue;} var dataElement = document.createElement('div'); var recElement = document.createElement('p'); recElement.innerHTML = rec; var collectionElement = document.createElement('p'); collectionElement.innerHTML = collection; } //you shouldn't use write after the document has been loaded //document.write(maxID);document.body.innerHTML = maxID; } });