Apache Lounge



Forum Index Downloads Search Register Log in  RSS Apache Lounge

Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.



A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.

With mod_rewrite AJAX can't load data

Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner

View previous topic :: View next topic  
Author Message

Joined: 10 Dec 2014
Posts: 1
Location: Lithuania

PostPosted: Thu 11 Dec '14 7:20    Post subject: With mod_rewrite AJAX can't load data Reply with quote

Rececntly I changed my platform URL from .com/company.php?id=50 to .com/company/company-name. Everything works good, except content, which should be loaded through AJAX.

My line in .htaccess:

RewriteRule ^company/([0-9a-zA-Z_-]+) company.php?id=$1 [NC,L]

The piece of AJAX, which is not loaded:

$rec_total_pages = ceil($amount_of_recommendations_company_has/$rec_per_page); // 2


$(document).ready(function() {
    var track_click = 0; //track user click on "load more" button, righ now it is 0 click
    var total_pages = <?php echo $rec_total_pages; ?>;
    var taker = <?php echo $recommendation_taker; ?>;
    $('#results').load("show_more_recs.php", {'page':track_click, 'taker':taker}, function() {track_click++;}); //initial data to load
    $(".load_more").click(function (e) { //user clicks on button   
        $(this).hide(); //hide load more button on click
        $('.animation_image').show(); //show loading image
        if(track_click <= total_pages) //user click number is still less than total pages
            $.post('show_more_recs.php',{'page':track_click, 'taker':taker}, function(data) {   
                $(".load_more").show(); //bring back load more button
                $("#results").append(data); //append data received from server
                $('.animation_image').hide(); //hide loading image once data is received   
                track_click++; //user click increment on load button
            }).fail(function(xhr, ajaxOptions, thrownError) { //any errors?
                alert(thrownError); //alert with HTTP error
                $(".load_more").show(); //bring back load more button
                $('.animation_image').hide(); //hide loading image once data is received
            if(track_click >= total_pages-1) //compare user click with page number


echo "<div id=\"results\"></div>
<a class=\"load_more more dark\" style=\"margin-left: 15px; margin-top: 5px; margin-bottom: 10px; cursor: pointer;\" id=\"load_more_button\"><span>Show more</span></a>
<div class=\"animation_image\" style=\"display:none;\"><img src=\"ajax-loader.gif\"> Loading...</div>

With new URL script can't even pass variables track_click, total_pages and taker. But there are no errors too.

What's the problem?
Back to top
James Blond

Joined: 19 Jan 2006
Posts: 6414
Location: Germany, Next to Hamburg

PostPosted: Thu 18 Dec '14 12:39    Post subject: Reply with quote

What do you use? $_GET? $_POST? Anything else?
Back to top

Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner
Page 1 of 1