S
S
Stanislav Kim2014-08-26 15:44:10
JavaScript
Stanislav Kim, 2014-08-26 15:44:10

How to solve ajax issue in Laravel 4?

Good afternoon. The problem is the following. There is a block and a button to update its content using AJAX. Everything works fine until I include an if condition in the controller that handles the ajax request.

public function postChangeEvents()
  {	
                if (Request::ajax()) {
    $date = time();
    $ids=Input::get('ids');
           if ($ids == 'today') { // то самое условие. если его убрать, то все работает отлично
                 $todayMor=mktime(0,0,0,(date('n',$date)),(date('j',$date)),(date('Y',$date)));
                 $todayEve=mktime(23,0,0,(date('n',$date)),(date('j',$date)),(date('Y',$date)));
                             return View::make('events.changeevents')->with('changeevents',Sobitiya::whereBetween('date', array($todayMor, $todayEve))->orderBy('date','asc')->get());    
                       }
                }
         }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Vinogradov, 2014-08-26
@pettson

Look at what headers are sent along with the request to the server. Perhaps there is no HTTP_X_REQUESTED_WITH.

V
Vyacheslav Plisko, 2014-08-26
@AmdY

Look at the error in app/storage/logs/laravel.log. I suspect from the name that $ids is an array, compared to a string.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question