dougudu3564 2017-01-05 17:07
浏览 73

$ .ajax“POST”上的内部服务器错误500

I have been getting an internal server error 500 for 8 days now and cannot find a way to solve it.

I want to make a search option for my users (when i get them, lol). I tried $.POST method alone, yesterday I changed it to $.ajax post method, and got the same results.

I think the error is coming from the URL properties. I tested every line of code and it does work, but when I go to URL everything goes to hell... Every time I put something different than "/wp-content/themes/yuuta/Food-Groups-BG.php" as my file path I get 404 NOT FOUND and when I put it back I get 500 internal server error... I had read every post that I could find on the internet and have tried many solutions and it won't work... :X

Here is my JQuery and PHP.

jQuery(document).ready(function ($) {
    $("#food_search").keyup(function(event){
        var search_term =$(this).val();
$.ajax({
    type:"POST",
    url:"/wp-content/themes/yuuta/Food-Groups-BG.php",
    data:{fsearch:search_term},
    success:function(res){
        $("#food_search_result").html(res);
    }
});
    });
});



<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<p>Търсене на храни: <input type="text" name="food-search" id="food_search"></p>

<!----------------------------------------------------------------
                                PHP
----------------------------------------------------------------->
<?php

$hostname = "localhost";
$username = "myName";
$password = "myPassword";
$databaseName = "dbName";

$connect = mysqli_connect($hostname, $username, $password, $databaseName);

if(isset($_POST['Title']) && $_POST['Title']!=""){
$fsearch = $connect->prepare("SELECT * FROM food_data_bg WHERE title LIKE :Title");
$fsearch->execute(array(
'Title'=>'%'.$_POST['Title'].'%'
));
if($fsearch->rowCount()==0){
echo 'Не бяха намерени резултати!';
}
else{
while($data=$fseach->fetch()){
?>
<div class="search-result">
    <img src="<?php echo $data['fimage']; ?>" class="fimage"/>
    <span class="result-title"><?php echo $data['title'];?></span><br>
    <span class="calories-total"><?php echo $data['calories total'];?></span><br>

</div>
<?php
}
}
}else
{
echo 'Напишете име на продукт!';
}
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
    • ¥20 易康econgnition精度验证
    • ¥15 msix packaging tool打包问题
    • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致