Load php file with jquery

Asked

Viewed 41 times

-1

Hello,

First of all I apologize if the question is not well structured.

I’m building a content/stock and similar management system.. I leave below a print screen where I try to explain how this structured folders/ directories.

In the index.php file I have the following:

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

In the root/system/functions.php file I have the following functions:

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');
  } 
}

In root/lang/lang.pt.php or lang.en.php I have the following: (among other translations)

DEFINE('users','Utilizadores');

In the root/js/main.js file I have:

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;
}

In the control/body.php file, I have a DIV With the main-panel-body ID, when I replace the contents of this div, through the jquery I show above, by the contents of the root/system/bodies/users.php file, does not load the php variables that the users.php file has, as for example translation variables. Issues an error.

I leave down the error:

Warning: Use of Undefined Constant users - assumed 'users' (this will throw an Error in a Future version of PHP) in

What am I doing wrong?

Thank you.

inserir a descrição da imagem aqui

1 answer

0

Hello, good night!

So this is not actually a MISTAKE, but a warning from Attention, you are probably using a version PHP that does not accept but the definition of constants in this way.

Current code example:

<?php
define("title", "Stack Overflow");
echo constant("title");
  • It doesn’t solve. I fixed what you gave me, and now it returns the error Warning: Constant(): Couldn’t Find Constant Users In

  • Colleague, you are saying that you did not enter the Users constant, you do the following, put the user code.php

  • No. I don’t. The user.php code is none for now. You only have an html table and nothing else.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.