I will try to explain my problem in a simple way. My code looks like these.
A web page, systemView.php, has following code
<?php require_once 'Common_Function.php'; ?>
<head>
<script src="jF.js"></script>
</head>
<html>
<div id="one"> <?php A(); ?> </div>
<div id="two"> </div>
</html>
Common_Function.php is
<?php
include 'systemView_Function.php';
include 'database.php';
?>
systemView.php has A() as well as B()
<?php
function A() {
D(); // a function in database.php
//and show a few button on the page
}
function B($number) {
D(); // a function in database.php
//some codes to show something in the page
}
if (isset($_POST['B'])) {
B($_POST['B']);
}
?>
A() function will show some buttons on the page when called. When one of the buttons is clicked. javascript will then call B() by ajax. This function in js is
$(".abutton").click(function(){
$("#two").empty();
var number = parseInt($(this).text());
$.ajax({
url: "./systemView_Function.php",
type: "POST",
data: {"B": number},
dataType: "JSON",
success: function(data) {
$("#two").append(data);
}
});
})
Now the problem is when D() is not included in B(), the codes run successfully and shows something in id="two" div. However, if D() is included in B(), console in browser shows errors, and nothing in second div.
POST http://localhost:8888/systemView_Function.php 500 (Internal Server Error)A()runs successfully?