[英]Ajax call to a php file not working with 'require_once' in that file
I basically have an ajax call to a php file: 我基本上有一个php文件的ajax调用:
$("#acceptBtn").click(function(){
$.ajax({
type: "POST",
url:"acceptOfferFunction.php",
data: {hash2: getURLParameter('hash2')},
success:function(result){
alert(result);
}
});
And for the sake of clarity here's the reduced version of that file illustrating the problem: 为了清楚起见,这里是该文件的简化版本,说明了问题:
<?php
session_start();
//require_once 'AcceptAnOfferFromEditor.php';
echo('foo');
?>
This works, 'foo' gets alerted, but should I uncomment the require_once
statement, it doesn't anymore. 这有效,'foo'会收到警报,但是如果我取消注释
require_once
语句,它就不再了。
The included file is a php class with many functions. 包含的文件是一个具有许多功能的php类。 It would be convenient to able to call them.
能够打电话给他们会很方便。
There is likely an error in your required file. 您所需的文件可能存在错误。 Enable error reporting to debug this:
启用错误报告以调试此操作:
<?php
session_start();
ini_set('display_errors', 1);
error_reporting(E_ALL);
require_once 'AcceptAnOfferFromEditor.php';
echo('foo');
Alternatively there might be a die()
or exit
call in the file. 或者,文件中可能存在
die()
或exit
调用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.