我在AjaxCall1'成功函数中创建AjaxCall2。但是我的AjaxCall2在ajaxcall1执行后最后被执行。任何人都建议我以其他方式做到这一点?
<script>
$(document).ready(function () {
var link;
$.ajax({
url: 'https://management.azure.com/subscriptions/ace9d0b5-941a-4c2d-b835-90ac43636f18/providers/Microsoft.Compute/virtualMachines?api-version=2017-12-01',
method: 'GET',
headers: { 'Authorization': 'Bearer @TempData["token"]'},
contentType: 'application/json; charset=utf-8',
success: function (result) {
var t = "<thead><tr><td>VM ID</td><td>VM Name</td><td>Location</td> <td>OSType</td><td>Type</td><td>bootDiagnostics Status</td></tr ></thead ><tbody>";
for (var i = 0; i < result.value.length; i++) {
// var net = GetNetworkData("fklnds");
link = result.value[i].properties.networkProfile.networkInterfaces[0].id;
alert(link);
t += "<tr><td>"
+ result.value[i].properties.vmId
+ "</td>"
+ "<td>" + result.value[i].name
+ "</td>" +
"<td>" + result.value[i].location
+ "</td>" +
"<td>" + result.value[i].properties.storageProfile.osDisk.osType
+ "</td>"
+ "<td>" + result.value[i].type
+ "</td>"
+ "<td>" + result.value[i].properties.diagnosticsProfile.bootDiagnostics.enabled
+ "</td>"
+ "<td>" + GetNetworkData("test") +
"</td></tr>";
}
t += "</tbody>";
$("#vmtab").html(t);
alert("Success");
},
error: function () {
alert("error");
var s = "<table><tr><td>asjklahs</td>" +
"<td>sdskjf*</td></tr>";
$("#target").html(s);
}
});
//get network data
});
var GetNetworkData = function (dass)
{
var op;
$.ajax({
url: 'https://management.azure.com/subscriptions/ace9d0b5-941a-4c2d-b835-90ac43636f18/resourceGroups/Jmeter-RG/providers/Microsoft.Network/networkInterfaces/jmetervm896?api-version=2015-06-15',
method: 'GET',
headers: { 'Authorization': 'Bearer @TempData["token"]' },
contentType: 'application/json; charset=utf-8',
success: function (data) {
op = data.properties.ipConfigurations[0].properties.privateIPAddress;
alert(op);
},
error: function () {
alert("Network error");
return null;
}
})
}
</script>
**我在AjaxCall1'成功函数中创建AjaxCall2。但是我的AjaxCall2在ajaxcall1执行后最后被执行。任何人都建议我以其他方式做到这一点? **