ajax在laravel中获取请求时出现500内部服务器错误?

时间:2017-04-06 07:28:23

标签: laravel-5

  路径文件中的

Route::get('griev_reg_form/assembly/{district_id}', 'GrievanceRegisterController@assembly');
  

在控制器中

public function assembly($id){
     $assemblyConstituency = AssemblyConstituency::where('dis_code', '=', $id)->orderBy(3)->get();
        $options = array();

        foreach ($assemblyConstituency as $assembly) {
            $options += array($assembly->ac_code => $assembly->ac_name);
        }

        return Response::json($options);
    }

在视图文件

   $("#district").change(function() {
            $.getJSON("griev_reg_form/assembly/" + $("#district").val(), function(data) {
                var $assembly = $("#ac_problem");
                $assembly.empty();
                $.each(data, function(index, value) {
                    $assembly.append('<option value="' + index +'">' + value + '</option>');
                });
           // $("#station_id").trigger("change"); /* trigger next drop down list not in the example */
            });
        });
  

当我更改选择框时,出现错误名称&#34; HTTP500:SERVER   错误 - 服务器遇到阻止的意外情况   它来自履行请求。&#34;

1 个答案:

答案 0 :(得分:0)

这是因为我没有在控制器中添加响应

use Response;