Question: If I have an array like this:

```

Array
(
    [0] => Array
        (
            [image_path] => 3blocks-02.png
        )

    [1] => Array
        (
            [image_path] => 2blocks-02.png
        )
)

```

Is there a way I can retrieve the ['image\_path'] value by the array index in a forreach loop?

I have tried:

```
foreach($images as $image)
{
   $image[1]
}

and 

foreach($images as $image)
{
   $image[1]['image_path']
}

```

and a key => value loop but I cant seem to get the data

Answer: 
Change your ajax url to this:

```
url: '/addFavorites',

```

and your route to this:

```
Route::post('/addFavorites', 'SearchController@addFavorites');

```

Just to make sure you point at the same url

> 
> EDIT:
> 
> 
> 

make sure that you have one route with **get** and the same route with **post**. see bellow:

Route::get('/addFavorites', 'SearchController@loadFavorites'); *<-to load the page*

Route::post('/addFavorites', 'SearchController@submitFavorites'); *<-to submit the data*

1. Change this: `$("#ajax-form").submit(function(event) {`

To this: `$('#yourid').click(function(){`
2. Remove the onclick in the 'a' element and add the `id='yourid'` with the name you want.
MethodNotAllowedHttpException usually comes when you haven't defined route or you have defined route for get method and you are using the route for post method. please check your routes.php