[英]Why is my php code not executing when ajax executes it
ok im trying to ajaxify my site and im having a major issue on the first page im working with raw ajax and using the responseText and on top of that there is a tree of files being used to use some functionality 好的,我试图将我的网站进行ajax化,并且在首页上出现了一个重大问题,即使用原始ajax并使用responseText,此外,还有一棵文件树用于使用某些功能
first here is the problem file code 首先是问题文件代码
<?php
echo 'apple'; // this runs
// is not returning or executing this
include('../core/init.php');
echo 'apple'; // this does not run
if(!empty($_POST)){
$validate = new validate();
if(token::check(input::get('token'))) {
$validation = $validate->check($_POST, array(
'title' => array(
'required' => true
),
'message' => array(
'required' => true
),
));
if ($validation->passed()) {
#create the post
$db_instance = DB::getInstance();
#check the value of private before submitting as there is an error there
$private = 0;
if(isset($_POST['private'])){
$private = 1;
}
if(@$db_instance->insert('feed',array(
'user_id' => $user->data()->id,
'title' => $_POST['title'],
'message' => $_POST['message'],
'private' => $private
))){
echo'updated the site activity';
}
}else{
foreach ($validation->errors() as $error) {
echo '<br>';
echo $error, '<br>';
}
echo '<br>';
}
}
}else{
echo '<p>error</p>';
}
?>
continuing this file is in an include tree like index->updateFeed->ajaxScript(has been run)->thiscode 继续此文件位于包含树中,如index-> updateFeed-> ajaxScript(已运行)-> thiscode
if anyone can explain without jquery and using a similar structure what is going wrong id be great ful 如果任何人都可以在没有jquery的情况下使用类似的结构进行解释,那么id会出错吗?
<?php
// lets us redirect using headers even if headers have already been sent out
ob_start();
session_start();
error_reporting(1);
// config
$GLOBALS['config'] = array(
'mysql' => array(
'host' => 'XXXXXXXXXXXXX',
'username' => 'XXXXXXXXXXXXX',
'password' => 'XXXXXXXXXXXXX',
'db' => 'XXXXXXXXXXXXX'
),
'remember' => array(
'cookie_name' => 'wpd_remember_cookie',
'cookie_expiry' => 2628000
),
'session' => array(
'session_name' => 'user',
'token_name' => 'CSRF_token'
)
);
// auto-load classes
spl_autoload_register(function($class){
require_once ('classes/' . $class . '.php');
});
require_once ('functions/sanitize.php');
require('functions/Gravatar.php'); //used for the gravatar
require('functions/email_verify.php');
//check if the user is logged in by tokens and if not don't log the user in other wise log them in
if(cookie::exists(config::get('remember/cookie_name')) && !session::exists(config::get('session/session_name'))){
$hash = cookie::get(config::get('remember/cookie_name'));
$hashCheck = DB::getInstance()->get('users_session', array('hash', '=', $hash ));
if($hashCheck->count()){
$user = new user ($hashCheck->first()->user_id);
$user->login();
}
}
?>
我忽略了某些东西,并暂时对其进行了修补,这是初始化文件在包含1级或更深的任何级别时不起作用的原因
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.