Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- VM205:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0
- at JSON.parse (<anonymous>)
- at Object.success (index.php:32)
- at i (jquery.min.js:631)
- at Object.fireWith [as resolveWith] (jquery.min.js:634)
- at A (jquery.min.js:1599)
- at XMLHttpRequest.<anonymous> (jquery.min.js:1628)
- <?php
- $conexion=mysql_connect("localhost","root","");
- mysql_select_db("802",$conexion);
- $result = mysql_query("SELECT * FROM usuarios", $conexion);
- $array = array();
- if($result){
- while ($row = mysql_fetch_array($result)){
- $Nombres = utf8_encode($row['ApellidoPaterno']);
- array_push($array, $Nombres); //nombres
- }
- }
- ?>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Autocomplete</title>
- <script type="text/javascript" src="jquery.min.js"></script>
- <script type="text/javascript" src="jquery-ui.js"></script>
- <script type="text/javascript" src="jquery.migrate.js"></script>
- <link rel="stylesheet" type="text/css" href="jquery-ui.css">
- </head>
- <body>
- <input id="tag">
- <br>
- <label>Nombre: </label>
- <h2 id="nombre"> </h2>
- <li id="results"></li>
- <script type="text/javascript">
- $(document).ready(function (){
- var items = <?= json_encode($array); ?>
- $("#tag").autocomplete({
- source: items,
- select: function(event, item){
- var params = {
- nombre: item.item.value
- };
- //ajax
- $.get("getodo.php",params, function(response){
- var json = JSON.parse(response);
- if(json.status == 200){
- $("#nombre").html(json.nombre);
- }else{
- }
- }); //ajax
- }
- });
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement