dimanche 25 février 2018

AJAX - Dynamically Changing Input Field

I'm stuck on something I haven't run across before. I have the following code in my Laravel project:

<div class="claimDocuments">
                @foreach($claim->attachments as $ca)
                    @if(Storage::mimeType($ca->attachmentPath) == "application/pdf")
                        <div class="document">
                            <a href="">
                            <img src="/images/Circle-icons-document.svg.png" class="img-circle" alt="Shipment" height="80px" width="80px"><br>
                            </a>
                            <div class="documentTitle">


     <span class="fa fa-check"></span>
                                    <input value="" class="form-control" name="title" type="text">
<input value="" class="form-control" name="attachmentID" type="text">
                                </div>

                            </div>

                    @endif
                @endforeach
                </div>

So basically there can be multiple ".document"'s in my page. There's an input field with a checkmark in it and I would like to change the value in my database solely by typing in a new value and clicking the checkmark.

The problem is, I would like to do this with AJAX, but I'm not all too familiar with this's and such.

So what would be the appropriate way to click the checkmark and have something similar to the below code be triggered?

$.ajax({
            type:'POST',
            url: '/carrier/claims/files/updateFile',
            data: {
                'attachmentID': $('input[name=attachmentID]').val(),
                'title': $('input[name=title]').val(),
               '_token': $('input[name=_token]').val(),
            },
                success: function(data) {......

I'd appreciate the help! Thank you - Matt



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

Aucun commentaire:

Enregistrer un commentaire