Reputation: 453
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.
Here is my progress for the javascript so far:
<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
Upvotes: 1
Views: 2797
Reputation: 8021
Set the $.get() datatype parameter to be text. jsyaml needs yml type text data to load.
Upvotes: 1