I am building a website using a technique I've never seen, and I may have just found out why, but I thought I'd check with those who know better than I. My project is set up with a Tasks.php that looks something like:
<?php
if($_GET['task'] == 'task1'){
$response = {'someTag':'someValue'};
}
if($_GET['task'] == 'task2'){
$response = {'someTag':'someValue'};
}
if($_GET['task'] == 'task3'){
if($_GET['info'] == 'someInfo'){
$response = {'someTag':'someValue'};
}
}
echo json_encode($response);
exit;
?>
this way, in my js I can essentially call php functions with ajax I.E.
$.get('Tasks.php',{'task':'task3','info':'someInfo'},function(response){
var data = JSON.parse(response);
console.log(data);
});
which would log a js object litteral:
{'someTag':'someValue'}
The problem I have is that my php has lost the functionality to do something like echo "$(body).append($('<div>'));";
Which would (using jquery) append a div to my document's body. The reason I'm doing it this way is because I want all my pages to have the html extension for other stuff. I would assume there's a way to possibly have that div there already, and reference it by id, or somehow make it visible with just php, and maybe my assumption is off base, or I need a plugin or extension or something, but, I need to confirm my crazyness(or stupidity).