I have a json file that I used in my project in this structure
<script src="js/main.js"></script>
<script>
var data = {"bills":[{"id":1,"name":"DStv","reference":"SmartCard Number","logo":"bill\/logo\/24Io6IqObQ8ddi5.jpg","active":1,"lifestyle":0},{"id":3,"name":"GOtv","reference":"IUC Number","logo":"bill\/logo\/mCNl5X1ZCfph4kg.jpg","active":1,"lifestyle":0},{"id":6,"name":"Startimes"...
</script>
<script src="js/bill.js"></script>
<script src="js/airtime.js"></script>
As you can see from the above example, the json file is already transferred to the data variable ... from which I have another external javascript file located under it.
Meanwhile, the json file is now created for reference, and I was told to use ajax to get json data in the project.
I have this code in my main.jsfile, I have the code below, but it is not available in the filebills.js
$(document).ready(function () {
$.ajax({
type: "GET",
url: "http://bills.payit.ng/bills/resources",
success: function(result)
{
data = result;
loadData(result);
}
});
});
source
share