保持我在我的页面中搜索的内容

时间:2018-02-19 01:01:48

标签: php ajax

我在一个网站上工作,我已经制作了一个php文件,显示我的搜索结果,(我正在处理请求预约)所以当我点击它有效但是唯一的问题是我的网页刷新,它显示一个空白页,直到我点击主页按钮重定向

//我的研究循环......

if(isset($_GET['submit-search'])) {
    $search = mysqli_real_escape_string($conn, $_GET['search']);
    $sql = "SELECT * FROM doctor WHERE DoctorFullName LIKE '%$search%' OR DoctorLocation LIKE '%$search%' OR DoctorSpeciality LIKE '%$search%'";
    $result = mysqli_query($conn, $sql);
    $queryResult = mysqli_num_rows($result);
        if ($queryResult > 0) {
?>
<div class="container overflow">
<div class="container overflow">
    <span class="mentor">
        <h2 class="display Text-mentor">
            <span class="mentor-admin">If the result shown bellow not seems like what you need then ;</span>
            <span class="mentor-admin-quote">select the speciality of the doctor you need and your insurance, and <span class="turquoise">search</span> again</span>
        </h2>
    </span>
</div>
<div class="container overflow">
    <p class="p-about-results"><?php echo "There is ".$queryResult." result matching your search"?></p>
    <p class="p-about-results">we hope that these results are the ones you are looking for :</p>
</div>
<?php
    while ($row = mysqli_fetch_assoc($result)) :
?>

//我的日历,所以我可以提交预约

<div id="myModal" class="modal">
    <!-- Modal content -->
    <div class="modal-content">
        <span class="close">&times;</span>
        <form>
            <input type="text" name="ap-time" id="t1" class="modal-input-text" placeholder="Choose a date">
            <div id="sub" style="top: 40px;left: 5px;z-index:1;text-align: center;"></div>
            <input type=submit name="ap_validation" value="request appointment" class="input-requestdate">
        </form>
    </div>
</div>

//我一直在努力的Ajax代码

<script type="text/javascript">
$(document).ready(function(){

    //alert("jquery is working");
    $(".input-requestdate").click(function(){
        var name = $(".modal-input-text").val();
        $.ajax({
            url: "Appointment.php",
            type: "POST",
            async: false,
            data: {
                "done": 1,
                "message": name,
            },
            success: function(data){

                alert("requested");
                window.location = window.location.href
            }
        })

    });

});
</script>`

感谢帮助:)

0 个答案:

没有答案