使用ajax更改外部php文件中的变量

时间:2014-03-17 14:16:14

标签: php ajax

我遇到了改变显示内容的php变量的问题 这是我的JS代码:

$(document).ready(function(){
        var ajax = 1;
        var button;
        $('.tagbtn').click(function(){
            button = $(this);
            $(this).siblings("ul").slideToggle('slow', function(){
                $('.selection').click(function(){
                    var number = $(this).children('h1').html();
                    button.html(number);
                    $(this).parent('ul').slideUp('slow');
                    var data = 'number=' + number;
                    $.ajax({
                        type:'POST',
                        //url: 'ajax-realizacje.html',
                        url: 'aktualnosci.class.php',
                        async: true,
                        data: data,
                        success: function(){
                            limit_page = number;
                        }
                    });
                });
            });

        });
    });    

limit_page是外部文件的变量,我正在尝试更改 这是我加载内容的php函数:

function LoadArticles($pages = 0, $page = 0) {

        $start = ($pages - $page) * $this->limit_page;

    $q = "SELECT p.*, d.title, d.title_url, d.content, d.content_short, d.tagi FROM " . $this->table . " p ";
    $q .= "LEFT JOIN " . $this->tableDescription . " d ON p.id=d.parent_id ";
    $q .= "WHERE d.language_id=? AND p.active=1 AND d.active=1 ";
    $q .= "ORDER BY p.date_add DESC, p.id DESC ";
    $q .= "LIMIT ?,? ";

    $params = array(
        array(dbStatement::INTEGER, _ID),
        array(dbStatement::INTEGER, $start),
        array(dbStatement::INTEGER, $this->limit_page)
    );
    $statement = $this->db->query($q, $params);
    $articles = array();
    while ($row = $statement->fetch_assoc()) {
        $row['content'] = strip_tags($row['content']);
        $row['url'] = BASE_URL . '/' . $this->modul . '/' . $row['title_url'] . '.html';
        $row['photo'] = $this->getPhotoUrl($row['photo']);
        $row['date_add_org'] = $row['date_add'];
        if (!empty($row['tagi'])) {
        $row['tagi_url'] = explode('|', str_replace(' ', '-', $row['tagi']));
        $row['tagi'] = explode('|', $row['tagi']);
        }
        $row['date_add'] = date("j", strtotime($row['date_add_org'])) . " " . miesiac2(date("n", strtotime($row['date_add_org']))) . " " . date("Y", strtotime($row['date_add_org'])) . "r";
        $articles[] = $row;
    }


    return $articles;
}

问题是ajax似乎没有改变那个php变量 非常感谢你的帮助

0 个答案:

没有答案