简体   繁体   English

相同的Javascript(SAP UI5)代码导致不同的数组

[英]Different array result in from same Javascript(SAP UI5) code

I am using cachebuster to determine the changes file in the application structure. 我正在使用cachebuster来确定应用程序结构中的更改文件。

Code that in the javascript file 在javascript文件中编码

在javascript文件中编码

Array result which doesnt work: 数组结果不起作用:

数组结果不起作用

Array result which works 数组结果有效

数组结果有效

I am not sure why the responses are different for the same piece of the code, the file which is being extracted looks similar in both the ajax calls. 我不确定为什么同一段代码的响应不同,正在提取的文件在两个ajax调用中看起来都相似。 Now please help me in unwrapping the result which doesnt work into a array like it looks in working result. 现在,请帮助我解开无法工作的结果,就像看起来在工作结果中一样。

The difference between the 2 responses was the working one was responding with current data type as JSON, where the issue with non working code is the response was send back with data type of text/html. 2个响应之间的区别是工作响应使用当前数据类型(如JSON)进行响应,其中非工作代码的问题是响应以text / html数据类型发送回。 I used JSON.parse on the response before being passed on to the next piece of code which resolved the issue i had. 在传递给解决我所遇到的问题的下一段代码之前,我在响应上使用了JSON.parse

var aChangeFilesPaths = Object.keys( JSON.parse (oCachebusterContent)); var aChangeFilesPaths = Object.keys( JSON.parse (oCachebusterContent));

在此处输入图片说明

Thanks all. 谢谢大家

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM