我有一个问题,导致我的变量“tempid”在放入第二个API调用时丢失了一些值。正如您从我的图像中看到的,如果我将变量记录到console (console.log(tempid)),它会显示得很好。然而,一旦我把它放在API调用中,它就有了一些值,但不是全部。你能帮我解释一下为什么会发生这种情况吗?
控制台示例
$(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
发布于 2021-10-18 07:38:08
我找到了答案,控制台只是显示了URL的缩短版本,并且碰巧切断了tempid的一部分。谢谢
https://stackoverflow.com/questions/69586067
复制相似问题