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 8856441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:21:26+00:00 2026-06-14T14:21:26+00:00

I have a problem with ajax and rewrite engin. I made a site, where

  • 0

I have a problem with ajax and rewrite engin. I made a site, where I use this load more script:

http://www.9lessons.info/2009/12/twitter-style-load-more-results-with.html

Everything works fine on users profile page (I am getting posts from users feedback), when the url looks like this: example.com/user.php?u=ExampleUser
but I have this in .htaccess:

RewriteRule ^u/(.*) user.php?u=$1 [L]

So if I type something like example.com/u/ExampleUser I get the username like:

$username = $_GET['u'];

But in this way when I click on the load more it doesn’t load more posts from the user, it just starts to lead the site itself to the div box (like it is an iframe…).
Please help me, it is necessary.
Here is my script, which should load more info from MySQL database($id is userid from DB):

$(function() {
    // More Button
    $('.more').live("click",function() {
        var ID = $(this).attr("id");
        if (ID) {
            $("#more" + ID).html('<img src="moreajax.gif" />');

            $.ajax({
                type: "POST",
                url: "ajax_more.php",
                data: 'lastmsg='+ID+'&user='+<? echo $id; ?>,
                cache: false,
                success: function(html) {
                    $("#container").append(html);
                    $("#more"+ID).remove();
                }
            });
        } else {
            $(".morebox").html('The End');
        }
        return false;
    });
});
  • 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-06-14T14:21:27+00:00Added an answer on June 14, 2026 at 2:21 pm

    Not knowing the entire context of your code, it looks like when the ajax call is made, the final url is something along the lines of domain.tld/u/ajax_more.php.

    I get around this issue by maintaining a list of constants in the javascript object.

    For example, I have a paths.php file that contains this:

    <?php
        header("Content-Type: text/javascript");
        echo "
            myNamespace.paths = {
                RELATIVE_FOLDER: '<?=RELATIVE_FOLDER?>',
                // add more as required...
            }
        ";
    ?>
    

    This is included in the page just like a regular script (with script tags), and from that point forward, myNamespace.paths will contain your constants, as returned by the server.

    In my case, if the URL was “http://www.example.org/path/to/my/dev/env”, I would have RELATIVE_FOLDER set to /path/to/my/dev/env/ on the server-side, which would then be included into the paths object.

    Later, in your ajax calls:

    $.ajax({
        type: "POST",
        url: myNamespace.paths.RELATIVE_FOLDER + "ajax_more.php",
        // ... everything else
    });
    

    I notice you have no problem with directly injecting PHP into your scripts. This is not necessarily a bad thing, but it does make it harder for you to minify your js. This is the reason why I went with a separate file to store the constants, instead of directly injecting it into the javascript itself with <?= ... ?> tags.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem with ajax loader image when I use the load() function, the
I have this problem that my sites uses alot of ajax and when a
I have a problem using ajax (jquery) and recursion. I call a php script
I have a problem with ajax requests, which forces me to use javascript linking.
One more question concerning JSF.Particularly, Primefaces. Have following problem with ajax update of elements
i have problem with load data from Database i use Primefaces (or other use
I have such code: <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js type=text/javascript></script> <script type=text/javascript> $(document).ready(function(){ var my_id = 'iddate';
i have problem.. for(a=1;a<10;a++){ $(.div).append(<div id=+a+></div>) $.ajax({ url: file.php, data: a=+a, type: POST, async:
i have a little problem with my Ajax calls. Maybe i do not have
I have a problem with an animation in jQuery using ajax. On the click

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.