weixin_33690963 2018-06-09 11:00 采纳率: 0%
浏览 30

为什么会一直收到“循环—内存限制”的消息提示?

我试图将表单中的信息存储到数据库中。但是,我持续收到了一个循环—内存限制的消息提示,我真的不知道它是如何出现的。

最初,我试图更改php.ini中的内存限制,因为我不知道是什么导致了问题。但是,我的盲目更改却导致了一系列更复杂的问题出来——怎么能解决一些你不知道它是如何产生的问题?

Route:

Route::resource('/office', 'OfficeController');

Form:

<form id="officeForm">
  <input type="text" name="office_name" placeholder="Има на офис..."><br>
  <input type="text" name="director" placeholder="Управител..."><br>
  <input type="text" name="address" placeholder="Адрес..."><br>
  <input type="text" name="phone_number" placeholder="Телефонен номер..."><br>
  <input type="text" name="working_time" placeholder="Работно време...">
  <button class="btn btn-primary" id="officeSubmit">Добавяне</button>
</form>

AJAX:

$('#officeSubmit').click(function(e) {
  e.preventDefault();
  $.ajaxSetup({
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
  });
  $.ajax({
    url: "/office",
    method: 'POST',
    data: {
      office_name: $('input[name=office_name]').val(),
      director: $('input[name=director]').val(),
      address: $('input[name=address]').val(),
      phone_number: $('input[name=phone_number]').val(),
      working_time: $('input[name=working_time]').val()
    },
    success: function() {
      $('input[name=office_name]').val('');
      $('input[name=director]').val('');
      $('input[name=address]').val('');
      $('input[name=phone_number]').val('');
      $('input[name=working_time]').val('');
    }
  });
});

Controller:

public function store(Request $request)
{
    $this->validate($request, [
        'office_name' => 'required',
        'director' => 'required',
        'address' => 'required',
        'phone_number' => 'required',
        'working_time' => 'required'
    ]);

    var_dump($request);

    $office = new Office();
    $office->office_name = $request->office_name;
    $office->director = $request->director;
    $office->address = $request->address;
    $office->phone_number = $request->phone_number;
    $office->working_time = $request->working_time;
    $office->save();

    return view('home');
}
  • 写回答

1条回答 默认 最新

  • weixin_33749131 2018-06-09 11:11
    关注

    In your ajax code you used

    method: 'POST',
    

    but In your route you declared it resource. try to change it to

    Router::post('/office', 'OfficeController@store');
    

    and also in your form you didn't write

    <form method="POST" .....>
    

    And in the last line on your store method you used

    return view('home');
    

    make that

    return redirect('/home');
    

    Also you can always check you browser's Network tab what code HTTP request returns. Is it 500 or others? 200 is OK. To get into network tab right click and select inspect elements there are other tabs like Elements, Console, Sources and then Network

    评论

报告相同问题?

悬赏问题

  • ¥15 数据量少可以用MK趋势分析吗
  • ¥15 使用VH6501干扰RTR位,CANoe上显示的错误帧不足32个就进入bus off快慢恢复,为什么?
  • ¥15 大智慧怎么编写一个选股程序
  • ¥100 python 调用 cgps 命令获取 实时位置信息
  • ¥15 两台交换机分别是trunk接口和access接口为何无法通信,通信过程是如何?
  • ¥15 C语言使用vscode编码错误
  • ¥15 用KSV5转成本时,如何不生成那笔中间凭证
  • ¥20 ensp怎么配置让PC1和PC2通讯上
  • ¥50 有没有适合匹配类似图中的运动规律的图像处理算法
  • ¥15 dnat基础问题,本机发出,别人返回的包,不能命中