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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵