I have a php script that executes a query against a mySQL database and returns an array. Here is the output:
[["185","177","8","10h:43m:54s","http:\/\/localhost\/toastReport\/cd7bf9ae-c21d-4746-bdd9-6934f8e5924e_ed13cfdc-403b-4a82-8f71-0da41a466e62_report\/feature-overview.html"]]
I am using ajax to call the PHP script and am then trying to load the data into a javascript array and then print out different values later in my HMTL page. Here is the javascript script I have in my page header:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript">
function myfunction() {
var automation = [];
jQuery.ajax({
type: "POST",
url: "http://localhost:8080/sanityTestDataCox.php",
success: function (jsonData) {
automation = jsonData;
console.log(automation);
}
});
}
</script>
I am trying to use the array data in a card at the top of my page:
<div class="card text-white bg-primary o-hidden h-100">
<a class="card-header text-white clearfix small z-1" href="#">
<span class="float-left">COX Sanity Run </span>
</a>
<div class="card-body">
<div class="card-body-icon">
<i class="fa fa-fw fa-tasks"></i>
</div>
<div class="mr-5">Total tests: <script type="text/javascript"> myfunction(); </script></div>
<div class="mr-5">Failed tests:</div>
<div class="mr-5">Passed tests:</div>
<span class="float-right"><div class="mr-5">Run Time:</div></span>
</div>
<a class="card-footer text-white clearfix small z-1" href="http:\//localhost\/toastReport\/cd7bf9ae-c21d-4746-bdd9-6934f8e5924e_ed13cfdc-403b-4a82-8f71-0da41a466e62_report\/feature-overview.html">
<span class="float-left">View Details</span>
<span class="float-right">
<i class="fa fa-angle-right"></i>
</span>
</a>
I am confused on how to make this work and any info or links to pages with a guide on how to make this work would be greatly appreciated. Thanks!