@extends('layouts.app')
@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-6 col-lg-6 col-sm-12 ">
            <div class="card">
                <div class="card-header">Agregar Item por URL</div>

                <div class="card-body p-30">
                    {!! BootForm::open()->action(route('backend.items.form.save'))->post() !!}
                    {!! BootForm::text('Url', 'item_url')->addClass('item-url-input') !!}
                    {!! BootForm::select('Categoria', 'category_id')->options($categories)->select(0) !!}

                    <br/>
                    <div class="col-md-8 col-lg-8 offset-md-3 offset-lg-3">
                        <div class="row justify-content-center">
                     <div class="col-md-6 col-lg-6 ">
                   <a href="#" class="btn btn-info item-url-verify">Verificar</a>
                    </div>
                    <div class="col-md-6 col-lg-6">
                    {!! BootForm::submit('Agregar')->addClass('btn btn-primary') !!}
                    </div>
                </div>
                    </div>
                    {!! BootForm::close() !!}
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
@section('scripts') 
    $('.item-url-verify').click(function() { 
       
    var url = $('.item-url-input').val();
    $.ajax({
         url: '{!! route('ajax.items.verify.url')!!}',
        type: 'GET',
        data: {'url':url},
        dataType: 'json', // added data type
        success: function(res) {
              alert(res.msg);
            console.log(res.msg);
          
        }
    });


}); 
@endsection
