Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6890331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:16:06+00:00 2026-05-27T06:16:06+00:00

All the strings on my site are pulled from a php language function named

  • 0

All the strings on my site are pulled from a php language function named lang() inside lang.php. The function works when I use it within the index.php file, ie:

<p><? echo lang('hello-world'); ?></p>

However, if I use elem.load('something.php');, where something.php contains the same above code, nothing gets returned. In fact, if I type:

<p><? echo haslkdfhasdf('hello-world'); ?></p>

I don’t even get an error. Now, after reading this Call PHP function in ajax and using header() I still don’t get a returned string. My question then is, why doesn’t the function work from inside an external php file loaded through AJAX, and what am I missing?

[EDIT]
Whoops forgot my AJAX code. Here’s what I’m using to load the file:

$('#main-content').load('_foo/views/error.php');

Here is the error.php file:

<p id="ajax-error-message">
<? echo lang('html'); ?>
</p>

Now, I know that the file loads because if I replace the function with “echo ‘Hello World’;” it displays it properly. And here is the site incase you need it: http://afoobar.com , when you click on HTML5 Sandbox it executes the AJAX.

I’ll try your suggestions in the mean time!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:16:07+00:00Added an answer on May 27, 2026 at 6:16 am

    Since I haven’t seen your JavaScript code (minus the elem.load() I can’t give you a guaranteed solution. I can, however, suggest that you change elem.load() for something like this:

    $.ajax({
        url: 'something.php',
        cache: false,
        success: function(response) {
            // do something
        },
        error: function(xhr, error) {
            try {
                console.debug(xhr); 
                console.debug(error);
            } catch (err) {
                alert(err);
            }
        }
    });
    

    Additionally, you could do practically the same thing using $.ajaxSetup();.

    EDIT

    Keep in mind that you have include (or require) all the needed files within your AJAX call because it is literally making a separate HTTP request.

    // at the top of error.php
    require_once '/path/to/lang.php';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can my webmethod only return strings like I see in all the asp.net site
how can I catch all strings from a native windows .exe file and replace
I'm making a site that will be translated into x languages. All strings must
On all the sample projects from apple's site (like Simple Drill Down) when I
I want to find all HTML tags from the input strings and removed/replace with
I need a regex that matches all strings ending in .cs, but if they
We would like to enumerate all strings in a resource file in .NET (resx
I wish to get a list of all strings that are used in a
I have an array of strings: @array I want to concatenate all strings beginning
Does Python have a pool of all strings and are they (strings) singletons there?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.