Like the title says, I'm doing an ajax call to a php file like this:
function loadForm(val1, val2, val3){
$.ajax({
url : 'AL_loadForm.php',
type : 'POST',
data : {
value1 :val1,
value2: val2,
value3:val3
},
dataType:'json',
success : function(data) {
alert(data);
},
error : function(request,error)
{
alert("error");
}
});
}
And in my loadForm.php I've got two cases, If I load this code I got a successful ajax call without error:
<?php
if($_POST){
$var1 = $_POST['value1'];
$var2 = $_POST['value2'];
$var3 = $_POST['value3'];
echo json_encode($var1);
}
?>
But if I load this same code with an include php file I get an error in my ajax call
<?php
if($_POST){
include 'AL_createTbObj.php';
$var1 = $_POST['value1'];
$var2 = $_POST['value2'];
$var3 = $_POST['value3'];
echo json_encode($var1);
}
Is this normal? can't do stuff in another php files with a single ajax call??
EDIT: to add content of AL_createTBObj.php, basically it creates an object from the class tableRows.php
<?php
require 'tableRows.php';
//Create mySqli object with DB Params
$conn = new mysqli($dbHost, $dbUser, $dbPass, $dbDB);
//Create TableRows object
$tb = new TableRows($conn);
//Connect to Data Base
$tb->checkDb();
?>
There is some echo 'content'
.. in the class tableRows.php but those methods aren't called yet....