laravel로 twitter typeahead.js를 사용하려고하지만 작동하지 않습니다.laravel과 함께 typeahead.js 사용
: 여기create.blade.php 내 코드
<!-- app/views/nerds/create.blade.php -->
<!DOCTYPE html>
<html>
<head>
<title>Crear Detalle</title>
<link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}">
<link rel="stylesheet" type="text/css" href="{{ URL::asset('css/main.css') }}" />
<script type="text/javascript" src="{{ URL::asset('js/jquery-2.1.1.min.js') }}" ></script>
<script type="text/javascript" src="{{ URL::asset('js/bootstrap.min.js') }}" ></script>
<script type="text/javascript" src="{{ URL::asset('js/typeahead.js') }}" ></script>
</head>
<script>
$(document).ready(function()
{
$.ajax({
type: "POST",
url: "http://chapincar.dev/notas_detalle/create",
data: "autocomplete="+$("input[name=autocomplete]").val(),
success: function(data)
{
json = $.parseJSON(data);//parseamos el json
var codigo = json
console.log(codigo)
$('#remote .typeahead').typeahead({
minLength: 3,
highlight: true,
},
{
name: 'codigo',
source: codigo
});
},
error: function(data)
{
json = $.parseJSON(data);//parseamos el json
var error = json
console.log(error)
}
});
});
</script>
<body>
<div class="container">
<nav class="navbar navbar-inverse">
<div class="navbar-header">
<a class="navbar-brand" href="{{ URL::to('nota_detalle') }}">Panel de Detalles de Ordenes</a>
</div>
<ul class="nav navbar-nav">
<li><a href="{{ URL::to('nota_detalle') }}">Ver todos los Detalles</a></li>
<li><a href="{{ URL::to('nota_detalle/create') }}">Crear un Detalle</a>
</ul>
</nav>
<h1>Crear Detalle</h1>
<!-- if there are creation errors, they will show here -->
{{ HTML::ul($errors->all())}}
{{ Form::open(array('url' => 'nota_detalle', 'class' => '')) }}
<table>
<tr>
<td class="ancho">
<div class="form-group">
{{ Form::label('codigo_nota', 'Codigo Orden') }}
{{ Form::text('codigo_nota', Input::old('codigo_nota'), array('class' => 'form-control')) }}
</div>
</td>
<td class="ancho">
<a href="#" class="btn btn-default"
data-toggle="modal"
data-target="#modalCliente">Buscar</a>
</td>
</tr>
<tr>
<td class="ancho">
<div class="form-group">
{{ Form::label('cantidad_detalle', 'Cantidad') }}
{{ Form::text('cantidad_detalle', Input::old('cantidad_detalle'), array('class' => 'form-control')) }}
</div>
</td>
</tr>
<tr>
<td class="ancho">
<div class="form-group">
{{ Form::label('descripcion_detalle', 'Descripción') }}
{{ Form::textarea('descripcion_detalle', Input::old('descripcion_detalle'), array('class' => 'form-control')) }}
</div>
</td>
</tr>
<tr>
<td class="ancho">
<div class="form-group">
{{ Form::label('precioIVA_detalle', 'Precio con IVA') }}
{{ Form::number('precioIVA_detalle', Input::old('precioIVA_detalle'), array('class' => 'form-control')) }}
</div>
</td>
</tr>
<tr>
<td class="ancho">
<div class="form-group">
{{ Form::label('precioSinIVA_detalle', 'Precio sin IVA') }}
{{ Form::number('precioSinIVA_detalle', null, array('class' => 'form-control', 'size' => '30x4')) }}
</div>
</td>
</tr>
<tr>
<td class="ancho">
<div class="form-group">
{{ Form::label('precioTotal_detalle', 'Precio Total') }}
{{ Form::number('precioTotal_detalle', null, array('class' => 'form-control')) }}
</div>
</td>
</tr>
</table>
{{ Form::submit('Agregar Detalle!', array('class' => 'btn btn-primary')) }}
{{ Form::close() }}
<!-- Modal -->
<div class="modal fade" id="modalCliente" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
<div class="form-group remote">
<label for="query">Search:</label>
<input class="form-control" name="autocomplete" id="autocomplete" placeholder="Start typing something to search..." type="text">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cerrar</button>
</div>
</div>
</div>
</div>
{{Form::close()}}
</div>
</body>
</html
>
이 내 routes.php 파일
Route::post("nota_detalle/create", function(){
$search = Input::get("autocomplete");
$query = DB::table("notas_cabecera")->where('chapa_vehiculo', 'LIKE', '%'.$search.'%')->get(['codigo_nota']);
Response::json($query);
});
이 내 오류 로그입니다입니다입니다
https://www.dropbox.com/s/1li3hhylw7ukbv0/Imagen%202.png?dl=0
는 서버 측에서 @Loz Cherone의 의견에 따라 그래서
디버깅하기 위해 할 일이 많을 수 있습니까? serverside는'querya ... '가 아닌'typeahead = ...'가 아닌 jQuery의 오류도 있습니다 : function (data) {console .log (데이터); ... '? –