Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. VM205:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0
  2. at JSON.parse (<anonymous>)
  3. at Object.success (index.php:32)
  4. at i (jquery.min.js:631)
  5. at Object.fireWith [as resolveWith] (jquery.min.js:634)
  6. at A (jquery.min.js:1599)
  7. at XMLHttpRequest.<anonymous> (jquery.min.js:1628)
  8.  
  9. <?php
  10. $conexion=mysql_connect("localhost","root","");
  11. mysql_select_db("802",$conexion);
  12. $result = mysql_query("SELECT * FROM usuarios", $conexion);
  13. $array = array();
  14. if($result){
  15. while ($row = mysql_fetch_array($result)){
  16. $Nombres = utf8_encode($row['ApellidoPaterno']);
  17. array_push($array, $Nombres); //nombres
  18.  
  19. }
  20. }
  21. ?>
  22. <html>
  23. <head>
  24. <meta charset="UTF-8">
  25. <title>Autocomplete</title>
  26.  
  27.  
  28. <script type="text/javascript" src="jquery.min.js"></script>
  29. <script type="text/javascript" src="jquery-ui.js"></script>
  30. <script type="text/javascript" src="jquery.migrate.js"></script>
  31. <link rel="stylesheet" type="text/css" href="jquery-ui.css">
  32.  
  33. </head>
  34. <body>
  35.  
  36. <input id="tag">
  37. <br>
  38. <label>Nombre: </label>
  39. <h2 id="nombre"> </h2>
  40. <li id="results"></li>
  41. <script type="text/javascript">
  42. $(document).ready(function (){
  43. var items = <?= json_encode($array); ?>
  44.  
  45. $("#tag").autocomplete({
  46. source: items,
  47. select: function(event, item){
  48. var params = {
  49. nombre: item.item.value
  50. };
  51. //ajax
  52. $.get("getodo.php",params, function(response){
  53.  
  54. var json = JSON.parse(response);
  55. if(json.status == 200){
  56. $("#nombre").html(json.nombre);
  57.  
  58. }else{
  59. }
  60. }); //ajax
  61.  
  62. }
  63. });
  64. });
  65. </script>
  66.  
  67. </body>
  68. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement