samedi 3 juin 2017

Laravel Route - Unable to fetch all post parameter

I'm using Laravel 5.4 and passing the form data using JQuery. Below is the JQuery code piece

 $('#upload_product').on('click', function () {
        var data = $("#create_post").serializeArray();
        data.push({images: jQuery.makeArray(files)});
        console.log(data);
        jQuery.ajax({
            url: '<?php echo $edit ? 'post/update' : '/sell/upload_product';?>',
            data: data,
            type: "POST",
            cache: false,
            error: function (xhr, textStatus, errorThrown) {
                console.log(xhr.status);
                console.log(xhr.responseText);
                console.log(errorThrown);
                console.log(textStatus);
            },
            success: function (data) {
                $('#postResult').html(data);
            }
        });
    });

Console data

enter image description here

Route

Route::post('/sell/upload_product', function (Request $request) {
    // echo $request[9];
    return view('_components.upload_product', ['title' => $request['title'], 'availability' => $request['availability'], 'category' => $request['category'],
        'subcategory' => $request['subcategory'], 'currency' => $request['currency'], 'price' => $request['price'], 'product_details' => $request['product_details'],
        'community' => $request['community'], 'images' => $request['images']]);
});

But $request['images'] giving empty result.

TIA



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2rp6PAc
via IFTTT

Aucun commentaire:

Enregistrer un commentaire