首页 > 解决方案 > Ajax 调用在 PHP 中返回 500 内部服务器错误

问题描述

在发送 Ajax 调用以调用 php 文件时,我在此文件上收到错误消息:

try {
    h.send(b.hasContent && b.data || null)
} catch (i) {
  if (c)
  throw i
}

这是我得到的错误:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

我确信我正在调用的 php 文件具有正确的地址,因为它可以在 localhost 上运行。

下面是我在 jQuery 中用来调用文件的 ajax 调用:

$(document).ready(function(){

    $.ajax({
        url: 'functions/getParishes.php',
        type: 'get',
        dataType: 'json',
        success:function(response){
            var len = response.length;

            $('#parish-list').empty()

            for( var i = 0; i<len; i++){

                $("#parish-list").append("<option value='"+response[i]['ID']+"'>"+response[i]['Name']+"</option>");

            }
        }
    });
});

有人可以说明我可能做错了什么吗?

标签: phpjqueryajax

解决方案


推荐阅读