I have an encoded object containing array of layers which is sent through an ajax call to some php file say myfile.php. The php file simply decodes this object and pushes the layers name into the database. Now i want to show layerName in front end which is currently pushing to the database.
My ajax request is as follows:
$.ajax(
{
type: 'POST',
url: "funcs.php",
data:
{
targetAction : 'getProjectAssetId',
MetaData: allFiles,
},
success: function(data)
{
console.log("data: "+data);
},
//dataType: "json"
});
Funcs.php encoded object handling is as follows:
if(isset($_POST['MetaData']))
{
$project= explode("ProjectTag",$_POST['MetaData']);
echo "
Project: ".$project[0]."
";
$projectName=explode("Bounds: ",$project[0]);
$projectBounds=$projectName[1];
$projectName=explode("ProjectName:",$projectName[0]);
$projectName=$projectName[1];
echo "ProjectName: ".($projectName)."
"."ProjectBounds: ".$projectBounds."
";
$bound=json_decode($projectBounds,true);
// Hard coded groupID and no reference ID
$projectId= getProjectAssetId($projectName,25,'',$bound,''); // inserting Project Name in DB with hardcoded groupID and no reference
echo "
ProjectId: ".$projectId."
";
$files=explode(",oneFileTag,",$project[1]);
for($fileCounter=0;$fileCounter<count($files);$fileCounter++)
{
$message='Adding Layer: '.$files[$fileCounter];
echo'<scripttype="text/javascript">alert(\'asd\');notification("'.$message.'",2,"loading"); </script>';
$Layer=explode("LayerFieldTag",$desFileFields[0]);
$LayerName=explode("LayerName:",$Layer[0]);
$LayerName=$LayerName[1];
echo "
LayerName: ".($LayerName)."
";
$typeId= getLayerAssetType($LayerName,1);
$layerId=getLayerAssetId($LayerName,$projectId);
echo "
typeid: ".$typeId."
";
echo "
Layerid: ".$layerId."
";
}
I want to execute javascript function in for loop, I mean I want to show all filenames in a dialog which is written in js files. The issue i am facing is it would be called by an echo but this echo would be caught on success function of ajax request. I want to execute this echo command.