变量在Ajax API调用中使用时会失去一些值



我有一个问题,导致我的变量" tempid "在第二次API调用时丢失了一些值。从我的图像中可以看到,如果我将变量记录到控制台(console.log(tempid)),它显示得很好。然而,一旦我把它放在API调用中,它就有了一些值,但不是全部。你能帮我解释一下为什么会这样吗?

[控制台例子][1]


$(document).ready(function() {

$.ajax({
url: "/api/Template/GetTemplates?classId=7ac62bd4-8fce-a150-3b40-16a39a61383d",
async:true,
dataType: 'json',
success: function(data) {

$(data).each(function (data) {
if (this.Name === "Name of Template"){
var tempid = this.Id
console.log (tempid)
var tempurl = "/api/V3/Projection/CreateProjectionByTemplate?id=" + tempid + "&createdById=703853d4-ffc4-fce3-3034-0b838d40c385"
$.ajax({
url: tempurl,
async: false,
dataType: 'json',
success: function(data) {
}
});
}
});
}
});
})

[1]: https://i.stack.imgur.com/gyesK.png

我找到了答案,控制台只是显示了URL的缩短版本,碰巧切断了部分temp。谢谢你

最新更新