I'm not even importing any files. All I want to do is transpose a HTML table (id = "valuation_table").
Here's the script I've used
<script>
$("#valuation_table").each(function() {
var $this = $(this);
var newrows = [];
$this.find("tr").each(function(){
var i = 0;
$(this).find("td, th").each(function(){
i++;
if(newrows[i] === undefined) { newrows[i] = $("<tr></tr>"); }
if(i == 1)
newrows[i].append("<th>" + this.innerHTML + "</th>");
else
newrows[i].append("<td>" + this.innerHTML + "</td>");
});
});
$this.find("tr").remove();
$.each(newrows, function(){
$this.append(this);
});
});
</script>
It works when I used this during the debugging phase. When I add it to the main project, it gives me the cross-origin frame error. All of my files are from the same source. I am not calling it from any link. My code so far reads an excel file from the disk, stores it to a database table, displays it, the js script is called here. I'm not calling an iframe.
The html file
<head>
<title>test</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<?php include_once 'tableSWAG.php'; ?>
<script>
$("#valuation_table").each(function() {
var $this = $(this);
var newrows = [];
$this.find("tr").each(function(){
var i = 0;
$(this).find("td, th").each(function(){
i++;
if(newrows[i] === undefined) { newrows[i] = $("<tr></tr>"); }
if(i == 1)
newrows[i].append("<th>" + this.innerHTML + "</th>");
else
newrows[i].append("<td>" + this.innerHTML + "</td>");
});
});
$this.find("tr").remove();
$.each(newrows, function(){
$this.append(this);
});
});
</script>
</body>
tableSwag.php
<?php
include_once 'swegAgain.php';
include_once 'db.php';
$sql = "select * from $table_name";
$result = $con->query($sql);
$nr = mysqli_num_rows($result);
$nc = mysqli_num_fields($result);
$recNew = array();
echo '<div id="peer_table">';
echo '<table id = "valuation_table" class="table table-bordered table-stripped table-condensed">' . "\n";
echo '<tr>
<th> </th>
<th>Sweg</th>
<th>Sweg1</th>
<th>Sweg2</th>
</tr>';
for($i = 1;$i <= $nr; $i++) {
echo '<tr>';
$records = mysqli_fetch_array($result);
for($j = 0; $j < $nc; $j++){
echo '<td>' . $records[$j] . '</td>';
}
echo "</tr>";
}
echo '</table>';
echo '</div>';
?>
This code works finally individually. When I integrate it the project that I'm working on, I get the cross-origin frame error. Any help would be appreciated.