Jump to content

Carregar ficheiro php com jquery


chicote

Recommended Posts

Olá,

Em primeiro peço desculpa se a pergunta não for bem estruturada.

Estou a contruir um sistema de gestão de conteudo/stocks e afins.. Deixo em baixo um print screen onde tento explicar como esta estrurada as pastas/directorias.

No ficheiro index.php tenho o seguinte:

<?PHP
require_once('sistema/functions.php');
require_once('control/head_load_script.php');
corpo_main();
require_once('control/footer.php');
?>

No ficheiro root/sistema/functions.php tenho as seguintes funcções:

function getLang(){
  if(!empty($_SESSION['usuarioID'])  == '' ){
    if(isSet($_GET['lang'])){
      $lang = $_GET['lang'];

      $_SESSION['lang'] = $lang;
      setcookie("lang", $lang, time() + (3600 * 24 * 30));
    } else if(isSet($_SESSION['lang'])){
      $lang = $_SESSION['lang'];
    } else if(isSet($_COOKIE['lang'])){
      $lang = $_COOKIE['lang'];
    } else{
      if(getSystemInfo('site_lang') == ''){
        $lang = "pt";
      } else {
        $lang = getSystemInfo('site_lang');
      }
    }
    include_once 'lang/lang.'.$lang.'.php';
  } else {
    $lang = getuserinfo('lang');
    include_once 'lang/lang.'.$lang.'.php';
  }
  DEFINE('langTag', $lang);
}
getLang();

function corpo_main(){
  if (!isset($_SESSION['usuarioID'])) {
    session_destroy();
    require_once('control/login.php'); 
  } else {
    require_once('control/header.php');
    require_once('control/corpo.php');
  } 
}

Nos ficheiros root/lang/lang.pt.php ou lang.en.php tenho o seguinte: (entre outras traduções)

DEFINE('users','Utilizadores');

No ficheiro root/js/main.js tenho:

getPage = function(page,title){
  $("#main-panel-body").empty();
  $( "#main-panel-body" ).load( "control/loader.html" );
  setTimeout(function(){
    $( "#main-panel-body" ).load( "sistema/corpos/"+page+".php" ); 
    $("#main-panel-body").empty();
  }, 2000); 
  document.title = title;
}

No ficheiro control/corpo.php, tenho uma DIV Com o ID main-panel-body, quando substituo o conteudo dessa div, atraves do jquery que mostro em cima, pelo conteudo do ficheiro root/sistema/corpos/users.php, não carrega as variaveis em php que o ficheiro users.php tem, como por exemplo variaveis de tradução. Emite um erro.

Deixo em baixo o erro:

Warning: Use of undefined constant users - assumed 'users' (this will throw an Error in a future version of PHP) in

O que estou eu a fazer de mal?

7jnaU.png

Obrigado.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.