project_folder
header.php
functions.php
PgetJson.php
js_folder
JSgetJson.js
fabric.min.js
sub_folder
another.php
In functions.php I am using wp_enqueue_script and wp_enqueue_style to include js and css files to project (custom Word press theme)function getJsonF(){ //////////////////////////////////// JSgetjson
var whichProjectToSave=document.getElementById("selectProjectID").value;
$.ajax({
method:"POST",
url: '/wp-content/themes/net/PgJson.php',
data: {
"getCanvas":1,
"whichProject":whichProjectToSave,
},
datatype: "text",
success: function(strdate){
canvas.loadFromJSON(strdate, function() {
// console .log(strdate);
canvas.renderAll();
});
}
});
}
from the server with code from PgetJson.php<?php ////////////////////////////////////////////////// PgetJson.php
$db2=mysqli_connect("localhost","ccc","ccc2","222cl_projectObjects")or die ("no connection");
if (isset($_POST["getCanvas"]) ) {
$projectName= mysqli_real_escape_string($db2, $_POST['whichProject']);
$query = "SELECT objectsList FROM projectObjectstable WHERE projectName='$projectName'";
$jsonCanvas= mysqli_query($db2,$query);
$row = mysqli_fetch_row($jsonCanvas);
$myLine=$row['0'];
echo $myLine;
}
mysqli_close($db2);
?>
<?php
...........
>
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
....
.........
</style>
<script type="text/javascript">
.......
var canvas = new fabric.Canvas('c7');
...........
</script>
</head>
<body>
.......
........
<canvas class="objectcanvas" id="c7" width="100" height="100" backgroundColor= "red" >
........
............
</body>
</html>
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Fellow title is reserved for select members who demonstrate sustained contributions, industry leadership, and outstanding performance. We will announce the experts being inducted into the Experts Exchange Fellowship during the annual Expert Awards, but unlike other awards, Fellow is a lifelong status. This title may not be given every year if there are no obvious candidates.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.