JQuery - Problema Autocomplete

   
Vista:

Problema Autocomplete

Publicado por Rubén (1 intervención) el 24/03/2017 11:33:26
No me funciona el autcomple, cuando hago debug el error es este:
POST http://localhost:63342/inside/search_books_external.php 404 (Not Found)
send
ajax
source
_search
(anonymous function)
search
(anonymous function)
(anonymous function)
handlerProxy

por mas que cambio la url en el jquery no cambia en el navegador paso a poner mi código:

HTML:
1
2
3
4
<form id="quick1" class="c-quick-search" action="view.php" method="get">
    <input type="text" name="titulo" placeholder="Introduce t�tulo o ISBN del libro" value="" class="form-control" id="search_books"/>
    <span class="c-theme-link">&times;</span>
</form>

JQUERY:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$( "#search_books" ).autocomplete({
    source: function( request, response ) {
        $.ajax({
            url: "../inside/search_books_external.php",
            dataType: 'json',
            type:'POST',
            data: {
                'term': request.term
            },
            success: function( data ) {
                response( data );
            }
        });
    },
 
    minLength: 3,
    select: function( event, ui ) {
        if(ui.item.id!="0"){
            //location.href='catalogo/'+ui.item.palabras_clave+'.htm';
            location.href='/'+ui.item.palabras_clave+'.htm';
        }
    }
});

PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
//include("app/webroot/edi/lib/connect.php");
//$term = htmlspecialchars(strip_tags($_POST['term']));
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "../global_variables.php";
include_once($path);
include ("../vendor/autoload.php");
include ("../vendor/bin/generated-conf/config.php");
use creadasClass\creadasClass\BooksQuery;
$term = htmlspecialchars(strip_tags($_POST['term']));
 
$exists = "EXISTS (SELECT u.id FROM customers c,users u,publishers p WHERE customer_id=c.id AND c.user_id=u.id AND u.publisher_id=p.id AND p.include_bookscc = 1)";
$filtro_editorial = "id IN (SELECT b.id FROM books b,customers c,users u WHERE publicar = '1' AND customer_id = c.id AND c.user_id = u.id AND u.publisher_id = $editorial)";
//$connect->query("SET collation_connection = utf8_bin");->ESTA LINEA TIENE QUE HACERSE EL SET
 
/*$con=Propel::getWriteConnection(creadasClass\creadasClass\Map\BooksTableMap::DATABASE_NAME);
$sql="SET collation_connection = utf8_bin";
$stmt = $con->prepare($sql);
$stmt->execute();*/
 
/*if ($term == utf8_decode($term)){
    $search = "publicar = 1 AND  publisher_id = $editorial AND  id IN (SELECT distinct book_id FROM editions WHERE  precio_papel>0 AND tipo='1' AND deleted='0' AND precio_papel IS NOT NULL) AND UPPER(titulo) LIKE UPPER('%".$term."%') AND ".$filtro_editorial." UNION SELECT id, titulo, palabras_clave FROM books b WHERE publicar = 1 AND id IN (SELECT distinct book_id FROM editions WHERE isbn LIKE '%".$term."%' AND precio_papel>0 AND tipo='1' AND deleted='0' AND precio_papel IS NOT NULL) AND  publisher_id = $editorial LIMIT 0,25";

    //$search = "SELECT id, titulo, palabras_clave FROM books b WHERE publicar = 1 AND  publisher_id = $editorial AND  id IN (SELECT distinct book_id FROM editions WHERE  precio_papel>0 AND tipo='1' AND deleted='0' AND precio_papel IS NOT NULL) AND UPPER(titulo) LIKE UPPER('%".$term."%') AND ".$filtro_editorial." UNION SELECT id, titulo, palabras_clave FROM books b WHERE publicar = 1 AND id IN (SELECT distinct book_id FROM editions WHERE isbn LIKE '%".$term."%' AND precio_papel>0 AND tipo='1' AND deleted='0' AND precio_papel IS NOT NULL) AND  publisher_id = $editorial LIMIT 0,25";

} else {
	$term = utf8_decode($term);
    $search = "publicar = 1 AND id IN (SELECT distinct book_id FROM editions WHERE  precio_papel>0 AND tipo='1' AND deleted='0' AND precio_papel IS NOT NULL) AND UPPER(titulo) LIKE UPPER('%".$term."%') COLLATE utf8_bin AND ".$filtro_editorial." AND  publisher_id = $editorial UNION SELECT id, titulo, palabras_clave FROM books b WHERE publicar = 1 AND id IN (SELECT distinct book_id FROM editions WHERE isbn LIKE '%".$term."%' AND precio_papel>0 AND tipo='1' AND deleted='0' AND precio_papel IS NOT NULL) AND  publisher_id = $editorial LIMIT 0,25 ";

    //$search = "SELECT id, titulo, palabras_clave FROM books b WHERE publicar = 1 AND id IN (SELECT distinct book_id FROM editions WHERE  precio_papel>0 AND tipo='1' AND deleted='0' AND precio_papel IS NOT NULL) AND UPPER(titulo) LIKE UPPER('%".$term."%') COLLATE utf8_bin AND ".$filtro_editorial." AND  publisher_id = $editorial UNION SELECT id, titulo, palabras_clave FROM books b WHERE publicar = 1 AND id IN (SELECT distinct book_id FROM editions WHERE isbn LIKE '%".$term."%' AND precio_papel>0 AND tipo='1' AND deleted='0' AND precio_papel IS NOT NULL) AND  publisher_id = $editorial LIMIT 0,25 ";
}*/
if (is_numeric($term)){
    $search="publicar = 1 AND id IN (SELECT distinct book_id FROM editions WHERE isbn LIKE ('%".$term."%') AND precio_papel>0 AND tipo='1' AND deleted='0' AND precio_papel IS NOT NULL) AND  publisher_id = $editorial LIMIT 0,25;";
}else {
    $search = "publicar = 1 AND id in (SELECT distinct book_id FROM editions WHERE  precio_papel>0 AND tipo='1' AND deleted='0' AND precio_papel IS NOT NULL) AND UPPER(titulo) LIKE UPPER('%" . $term . "%') AND $filtro_editorial AND publisher_id = $editorial LIMIT 0,25;";
}

//$result = $connect->query($search);
$result=BooksQuery::create()
    ->where($search)
    ->find();
 
$countSearch = $result->count();
if($countSearch == "0"){
	$row['value']="Sin Resultados";
    $row['id']="0";
    $row_set[]=$row;
}else{
	$i=0;
	//while($rowB = @mysqli_fetch_array($result)){
    foreach ($result as $rowB){
    	$row['value']=utf8_encode($rowB->getTitulo());
        $row['id']=$rowB->getId();
        $row['palabras_clave']=utf8_encode($rowB->getPalabrasClave());
        $row_set[]=$row;
        $i++;
    }
}
echo json_encode($row_set);
?>
Gracias de antemano
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve

Problema Autocomplete

Publicado por xve (657 intervenciones) el 24/03/2017 17:55:40
Hola Rubén, el error es claro, no encuentra el archivo en la ubicación indicada en el ajax!!!

Si cambias la url te da el mismo error al refrescar la página?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Revisar política de publicidad