[英]Load yaml file using javascript and get the data in the yaml file
I am creating a function to load a yaml file via javascript and however I am stuck on how to get the data from the yaml file where I will subsequently use the data to fill up labels in my HTML page.我正在创建一个函数来通过 javascript 加载一个 yaml 文件,但是我被困在如何从 yaml 文件中获取数据,然后我将使用这些数据来填充我的 HTML 页面中的标签。
Here is my progress for the javascript so far:到目前为止,这是我在 javascript 方面的进展:
<script>
// YAML file to Javascript object
$.get( 'yaml/cars_loan.yaml', function( text ) {
var obj = jsyaml.load( text );
console.log( obj );
});
</script>
*This is the updated correct codes *这是更新后的正确代码
Set the $.get() datatype parameter to be text.将 $.get() 数据类型参数设置为文本。 jsyaml needs yml type text data to load. jsyaml 需要 yml 类型的文本数据来加载。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.