Use JSON but not see results

wdr.leo's Avatar

wdr.leo

07 Aug, 2012 07:40 PM

data.php;
<?php
include '../inc/data_base.inc.php';
$input = $_GET["q"]; $data = array(); // query your DataBase here looking for a match to $input $query = mysql_query("SELECT id,nick FROM uyeler WHERE nick LIKE '%$input%'"); while ($row = mysql_fetch_assoc($query)) {
$json = array(); $json['value'] = $row['id']; $json['name'] = $row['nick']; $data[] = $json; } echo 'var data = {items: '.json_encode($data).'}';
?>

header;

http://localhost/cemvenuray/js/data.php

Write "vi" in input,return values the data.php;
var data = {items: [{value

But results not see.
if not use json working but if use json not working.

How use it with json?

  1. 1 Posted by wdr.leo on 07 Aug, 2012 07:52 PM

    wdr.leo's Avatar

    Sorry,forgot code ta;
    data.php;

    
    
    

    header;

    
    $(function(){
    var data = $.getJSON('http://localhost/cemvenuray/js/data.php'); 
    });
    $("input[name=kisiler]").autoSuggest(data.items, {selectedItemProp: "name", searchObjProps: "name"});
    
  2. 2 Posted by flth on 07 Aug, 2012 10:10 PM

    flth's Avatar

    played around with it at the same time like you.... found the solution, use the following function

    $(document).ready(function() {
        $("input[type=text]").autoSuggest("query.php", {selectedItemProp: "name", selectedValuesProp: "value", searchObjProps: "name", minChars: 1, matchCase: false}
        );
      });
    
  3. 3 Posted by wdr.leo on 08 Aug, 2012 01:30 AM

    wdr.leo's Avatar

    Not working :(
    Is it possible to give a simple example script, running of use json?

  4. 4 Posted by wdr.leo on 08 Aug, 2012 01:33 AM

    wdr.leo's Avatar

    Sorry,image false cut.
    Return value's image;
    values returning but not view

  5. 5 Posted by wdr.leo on 09 Aug, 2012 08:00 AM

    wdr.leo's Avatar

    Not solved problem,help pls.

  6. 6 Posted by Jon on 09 Aug, 2012 09:47 AM

    Jon's Avatar

    I think your JSON is not correct. It should be something like this:

    [{"value": "1", "name": "ViPeR"}, {"value":"87","name":"pervin"}]
    
  7. 7 Posted by wdr.leo on 10 Aug, 2012 03:03 PM

    wdr.leo's Avatar

    Hey jon :) too thanks! You answer tru problem solved.

  8. 8 Posted by wdr.leo on 10 Aug, 2012 10:16 PM

    wdr.leo's Avatar

    Ok, how to disabled tab key ?

  9. 9 Posted by Jon on 13 Aug, 2012 06:25 AM

    Jon's Avatar

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac