ajaxurl = "fetchData.php"
data = {'a':item1,'b':item2,'c':item3,'d':item4,'e':item5,'f':item6}
function includeJsFile(jsFileName)
{
//var head = document.getElementsByTagName('head')[0];
script = document.createElement('script');
script.src = jsFileName;
script.type = 'text/javascript';
document.head.appendChild(script);
}
$.post(ajaxurl, data, function (response) {
var resp = $.parseJSON(response);
drawGraph(
Description of the scenario ); });
An issue I am facing is that localArr[0] holds the name of the object property to clone. For example, it could be "colGraphProps"
. This variable is specified in
"propsConfig.js"
which I am attempting to load earlier in this context. However, $localArr[0] is surrounded by double quotes in the JSON response, causing the actual value of the variable not to be substituted. How can I resolve this? Also, I am unsure if the includeJsFile function successfully loads the JS files (no errors are seen during execution)
The PHP file mainly runs a database query and delivers the results
fetchData.php
Sample code snippet
if ($result) {
$ajaxResp = [
sample content
];
echo json_encode($ajaxResp);
}
I am open to modifying my approach if the situation demands. Your assistance would be greatly appreciated.