The following is my jquery/javascript code in my javascript file:
function userInput(){
var name = form1.elements["name"].value;
names1.push(name);
console.log(names1);
for(m=0; m<names.length; m++){
console.log(names[m]);
console.log(names1[0]);
if (names[m] == names1[0]){
flag = "no";
m = names.length;
}
else{
flag = "yes";
}
console.log(names[m]);
console.log(names1[0]);
}
$.ajax({
url:"test.php", //the page containing php script
type: "get", //request type
success:function(result){
alert(result);
console.log("post worked! :D");
}
});
//run python training script here! send over names parameter
};
The following is test.php:
<?php
echo("Hello World");
?>
In my html, I call UserInput() in a form so that when a button is clicked, this function runs. This part is working as expected. The issue that is occurring is that the Javascript runs the "test.php" code, however, when this is called, the website displays a pop up with all of the php code listed. I'm unsure of why this is occurring...I don't think it's because of the php code because I've tried multiple lines of PHP code that did not include echo and such..let me know if you need me to include any more information!