Level 5
use axios https://github.com/mzabriskie/axios
how i can pass this this value to my controller any ideas?
<div id="container">
<h2>D</h2>
<form method="post" action="{{url('select2')}}">
{{ csrf_field() }}
<div id="form1">
</div>
<div > <input type="submit" name="submit" type="button">
</div>
</form>
</div>
<script type="text/javascript">
$(document).ready(function() {
debugger
var i=0;
var input=[];
@foreach($result as $s)
@if($s->fieldtype=='text')
$("#form1").append('<div class="row"><label>{{$s->fieldname}}
</label><input type="text" name="name" id="name.concat({{$s->id}})"></div>');
@elseif($s->fieldtype=='textarea')
$("#form1").append('<div class="row">{{$s->fieldname}}<input
type="text" id="{{$s->id}}"><input type="hidden" value="{{$s->id}}" id="name"> </div>');
@endif
input[i++] = document.getElementById("{{$s->id}}").value;
@endforeach
$("#submit").click(function() {
$.ajax({
url:'/select2',
type: 'POST',
dataType:'json',
contentType: 'application/json',
data: {'data': input, '_token' : $('#_token').val()}
});
});
});
</script>
Please or to participate in this conversation.