首页 > 解决方案 > 重写url后Ajax jQuery不起作用

问题描述

我有问题为什么这不起作用。我修改 .htaccess 以删除 .php 扩展名

所以这是我的 htaccess

<IfModule mod_rewrite.c> 
        RewriteEngine on

        # To remove trailing slash
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_URI} /(.*)/$
        RewriteRule ^ /%1 [R=301,L]

        # To remove .php extension
        RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ (.*)\.php [NC]
        RewriteRule ^ %1 [R=301,L]

        # To check whether the file exists then set it back internally
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME}.php -f
        RewriteRule ^.*$ $0.php [L]

        # To redirect /index to root
        RewriteCond %{THE_REQUEST} ^.*/index
        RewriteRule ^(.*)index.php$ /$1 [R=301,L]

        </IfModule>

这是我的ajax代码

function setStatus(response) {
$.ajax({
    type:'POST',
    url:'status?status',
    data:{response:response},
    dataType: 'json',
    success:function(response){
    $('#status').text(response.status);
    $('#fight_number').text(response.fight_no);
    $('#result').text(response.result);
    $('#total_bet').text("Total Bet Points : " + response.total_bet_points);
    $('#points').text("Your Points : " + response.user_points);
    $('#meron_counter').text(response.m_side);
    $('#wala_counter').text(response.w_side);
    $('#draw_counter').text(response.d_side);
    $('#cancel_counter').text(response.c_side);
    $('#ol').text(response.online_count);
    var au = $('.audio').attr('id')
    if(response.status_now === 500) {
    if(response.events === au) {
     setAudio(response.chat_type);
     }
    }
   },
   error: function(jqXHR, textStatus, errorThrown){

  }
});

}

在修改 htaccess 并删除 .php 之前代码工作正常,所以我在 ajax i 中从 status.php?status 更改为 status?status

为什么这不起作用

谢谢你

标签: jqueryajax.htaccess

解决方案


推荐阅读