vendredi 26 mai 2017

undefinded value javascript laravel

I need when open modal to pass week id and insert data into db with ajax in js the db columns are : user_id week_id book_name author pages category this is php code

 @foreach($weeks as $week)
        @if(Auth::user() == $week->user)
            <table class="table table-bordered tar" id="week" data-weekid="">
                <span class="input-group-addon" id="basic-addon1"><i class="fa fa-table" aria-hidden="true"> <h4></h4></i></span>
                <thead>

        <tr>

            <th style="background-color: #f0f0f0; color: #5d6d7e; text-align: center">الخيارات</th>
            <th style="background-color: #3cb774; color: #FFFFFF; text-align: center">الإنجاز</th>
            <th style="background-color: #e85657; color: #FFFFFF ; text-align: center">عدد الصفحات</th>
            <th style="background-color: #ff6a06; color: #FFFFFF ; text-align: center">المجال</th>
            <th style="background-color: #2c81ba; color: #FFFFFF ; text-align: center">المؤلف</th>
            <th style="background-color: #0f7864; color: #FFFFFF ; text-align: center">اسم الكتاب</th>
            <th style="background-color: #5d6d7e; color: #FFFFFF ; text-align: center">اليوم</th>
        </tr>
        </thead>
                 <tbody class="tbody1">



                    <tr data-pageid="" name="" class="tr1">
                      <td>
                        <a href="#"><i class="glyphicon glyphicon-pencil" aria-hidden="true"></i></a>
                        <a href="#"><i class="glyphicon glyphicon-remove" aria-hidden="true"></i></a>
                      </td>
                       <td></td>
                       <td></td>
                       <td></td>
                       <td></td>
                       <td></td>
                        <th scope="row"></th>
                        <button type="submit" id="addbook" class="btn btn-success btn-lg btn-block update_user_button">إضافة كتاب</button>

                     </tr>
        </tbody>
    </table>
        @endif
    @endforeach

and this js code and returning value undefinded

$('.update_user_button').on('click', function (event) {
    event.preventDefault();


    m = event.target.dataset['weekid'];
    alert(m);
    $('#edit-modal').modal();
});


$('#modal-save').on('click', function () {
    $.ajax({
        method: 'POST',
        url: '',
        data: {
            days: $('#day').val(),
            book_name: $('#book').val(),
            author: $('#author').val(),
            page: $('#page').val(),
            _token: token
        }
    })
        .done(function (msg) {

            $('#edit-modal').modal('hide');
        });
});



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

Aucun commentaire:

Enregistrer un commentaire