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 JS定时器制作实时时间计数器
  • ¥25 matlab无法将表达式转换为双数组怎么解决?
  • ¥15 单片机汇编语言相关程序
  • ¥20 家用射频美容仪技术规格
  • ¥15 大家帮我看看为什么错了
  • ¥15 unity互动琴弦抖动效果
  • ¥15 做了个的二极管反向饱和电流测量电路,但是测试达不到效果
  • ¥15 nginx无证书访问https失败
  • ¥15 树莓派启动AP热点传入数据
  • ¥15 multisim中关于74ls192n和DSWPK开关的问题(相关搜索:计数器)