想要通过 php javascript 和 ajax 在 URL 中使用单词


Want to use word in URL by php javascript and ajax

在我的php中

$t_keyword= $_GET['user'];设置文件中

我想在 http://www.domain.com/index.php?user="Roni" 中使用在上面运行 url ajax 不起作用,但如果我在设置文件$t_keyword= 'roni';中设置它的工作

如何工作 http://www.domain.com/index.php?user="罗尼"

我的代码索引.php

<?php require 'settings.php'; ?>
<html>
    <head>
        <title></title>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
        <style type="text/css">
        #fetched-torrents span{float: left;height:20px;}
        #fetched-torrents div span:nth-child(even){background: #c0c0c0;}
        #fetched-torrents div{float:left; clear: both;}
        .t-link{width: 100px; overflow: hidden;}
        .t-name{width: 300px; overflow: hidden;}
        .t-size{width: 150px; overflow: hidden; text-align: right;}
        .t-se{width: 110px; overflow: hidden; text-align: right;}
        .t-le{width: 110px; overflow: hidden; text-align: right;}
        .t-ve{width: 100px; overflow: hidden; color: green;}
        </style>
    </head>
    <body>
        <script type="text/javascript">
        function search(){
            $.ajax({
                url: 'search.php',
                beforeSend: function(jqXHR){
                    $('#status').html('<img src="images/loading.gif" width="16" height="16" alt="+" />');
                },
                success: function(data){
                    if(data.error!=undefined){
                        $('#status').html(data.error);
                        return;
                    }
                    $('#status').html('');
                    var t_displayed=0;
                    for(var x in data){
                        if(data[x].ver==0){
                            continue;
                        }
                        if(t_displayed>=t_max){
                            break;
                        }
                        t_displayed++;
                        $('#fetched-torrents').append(''
                            <div>'
                                <span class="t-link"><a href="'+data[x].hhss+'">a</a></span>'
                                <span class="t-name">'+data[x].saas+'</span>'
                                <span class="t-size"> '+bytesToSize(data[x].ssa, 2)+'</span>'
                                <span class="t-ss">'+data[x].sff+'</span>'
                                <span class="t-lss">'+data[x].dff+'</span>'
                                <span class="t-ves">Veris</span>'
                            </div>'
                        ');
                    }
                },
                dataType: 'JSON'
            });
        }
        var t_max=<?php echo $t_max;?>;
        $(function(){
            search();
        });
        </script>
        <div id="status"></div>
        <div id="fetched"></div>
    </body>
</html>

在 url 后添加后,我的问题解决了:)

        $.ajax({
            url: 'search.php',
            data: 'user=<?php echo $keyword;?>',