jQuery-Ajax 在生产服务器上不起作用


jQuery-Ajax dont work on production server

我创建了一个Web应用程序,基本思想是有一个页面,然后使用ajax插入来自php-mysql脚本的数据。在本地 Xampp 上,该应用程序运行完美。

在生产服务器上,一些 ajax 请求有效,但其他请求不起作用。

铬检查元素显示错误:

POST mysite.com/app/show_staff_profile_ajax.php 500 (Internal Server Error) jquery-2.0.3.js:7845
send  jquery-2.0.3.js:7845
jQuery.extend.ajax jquery-2.0.3.js:7301
showProfile ajax.js:466
(anonymous function) ajax.js:150
jQuery.event.dispatch jquery-2.0.3.js:4676
elemData.handle jquery-2.0.3.js:4360

在 ajax 上.js第 150 行我得到:

$(document).on('click','.show_profile',function(){
    var id = $(this).attr("id");
    showProfile(id);  //line 150
    return false;
});

在第 446 行:

function showProfile(id){
    $.ajax({   //line 446
        type:"POST",
        url: "show_staff_profile_ajax.php",
        data: {id : id},
        success: function(data)
        {
            $("#program_panel").html(data);
        }
    });
}

在show_staff_profile_ajax.php上,我正在从mysql和echo获取数据带有php变量的html标签

我正在尝试两天来解决这个问题。我读过很多帖子,但似乎没有任何效果

> 500 错误表示show_staff_profile_ajax.php文件中存在错误。尝试获取有关此的更多信息 - php 应用程序通常有一个错误日志文件。找到它,它可能会为您提供有关导致错误的原因的更多信息。

您在 ajax 调用中传递的唯一数据是"id",所以我也会看看它。也许放一行这样的行:

console.log('profile id: ' + id);

就在你运行showProfile(id)在你的点击函数之前。可能存在某些 HTML 元素具有不正确的数据 ID 值。这应该在错误发生之前在控制台中显示 id。

正如 karhikr 所说,500 错误表示错误在您的服务器上,而不是在他们的浏览器中。

Xampp 是一个 Windows 软件包,Windows 不区分大小写并且对写入权限放宽 - 如果将站点移动到 Linux 环境已经破坏了它,那么很可能这就是您的问题所在 - 500 错误更有可能是写入权限错误而不是大写错误。