jquery post调用不在URL的末尾使用斜杠

时间:2015-05-08 13:29:00

标签: javascript php jquery .htaccess

示例网址
目标不是显示.php扩展名,但内容在页面/网址打开时停止工作,最后使用斜杠。
http://www.example.com/manager/create - 表单正在使用此网址 http://www.example.com/manager/create/ - 表单无法使用此网址

文件夹&文件:
|
| /js/custom.js
| /manager/create.php
| /manager/creategetpostdata.php
| /manager/.htaccess

custom.js上的内容

$(window).load(function() {
    // get post code data
    $('.contentfinder').on('keyup', function(e){
        var xyz = $(this).closest('.contentRow');
        //alert( "success" );
        $.post("../manager/creategetpostdata.php", xyz.find('.contentfinder').serialize(),  function(response) {
            //alert( "success" );
            xyz.children('.showPostData').html(response);
            xyz.children('.showPostData').show();
        });

    });

});

在create.php文件上输入表单:

                    <div class="contentRow">
                        <input type="text" name="inputdata" class="form-control contentfinder" placeholder="" />
                        <div class="showPostData"></div>
                    </div>

关于creategetpostdata.php的内容

<?php echo 'hello, what the hell wrong with you. just show content now!'; ?>
.htaccess文件

内容

Options +FollowSymLinks -MultiViews
RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+(.+?)\.php\?([^=]+)=([^\s&]+) [NC]
RewriteRule ^ /%1/%2/%3? [R=302,L,NE]

RewriteCond %{THE_REQUEST} \s/+(.+?)\.php\s [NC]
RewriteRule ^ /%1 [R=302,L,NE]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

任何帮助? 提前谢谢。

|| - ||更新 - 解决了|| - ||

    var loc = window.location.pathname;
    var dir = loc.substring(0, loc.lastIndexOf('/create'));

        $.post( dir + "/creategetpostdata.php", xyz.find('.contentfinder').serialize(),  function(response) {
            //alert( "success" );
            xyz.children('.showPostData').html(response);
            xyz.children('.showPostData').show();
        });

0 个答案:

没有答案