php - jQuery JSONP "undefined" response -


I know there are so many questions about JSNP - I have gone through all the answers practically and - Cannot- Why do not I get the right result for my life? I've spent many hours, really going back to the hours ahead, trying different tunes, etc. Anyway, to pile it under:

My script (on the same page as my form)

  $ (function () {function log (message ) {$ ("& Lt; div & gt;") .text (message) .prependTo ("#log"); $ ("#log") .scrollTop (0);} $ ("# name"). Autocomplete ({source: function (request, response) {$ .ajax ({url: "search.php", jsonp: "callback", data: {word: request.term}, data type: "jsonp" Type: "GET", success: function (data, position) {if (position == "success") {$ ("# log"). Html (response);} response ($ .map (Data, function (item) {return {label: item.label, value: item.value}}}))}}};}, minnabbon: 2, select: function (event, ui) {log (ui .item? "Selected:" + ui.item.label + ui. Item.value: "None was selected, input was" + this.value);}, open: function () {$ (this) .removeClass ( "Ui-corner-all") .addClass ("ui-corner-top");}, close: function () {$ (this) .removeClass ("ui-corner-top") .addClass ("ui- Corner-all ");}}};});   

My form (same page as script)

  & lt; Form method = "post" action = "" & gt; Name: & lt; Input type = "text" id = "name" name = "name" /> & Lt; / Form & gt; & Lt; Div class = "ui-widget" style = "margin-top: 2em; font-family: aerial" id = "log" & gt; & Lt; P & gt; Results & lt; / P & gt; & Lt; / Div & gt;   

My search. Php

  if (empty ($ _GET ['term'])) exit; 'Php / config / sql.inc.php' is required; $ Link = mysqli_connect (MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_NAME) or die (sqlerror (mysqli_error ($ link), __LINE__, __FILE__)); $ Req = "supplier_id, supplier_name to supplier_name where 'mysqli_real_escape_string ($ link, $ _gET [' term ']), like supplier_name." $' "; $ Query = mysqli_query ($ link, $ req); ($ Line = mysqli_fetch_array {$ query}} {$ Result [] = array ('data' = & gt; array ('value' = & gt; $ line ['supplier_id'], 'label' = & gt; $ row [ Header ('cache-control: no-cache, east-reckoned'); header ('expiry: Mon, 26 November 2014 05:00:00 GMT'); Header (' Content-type: application / jason '); resonance ((isset ($ _GET [' callback ']) $ _GET [' callback ']. (' .json_encode ($ result). ')': Json_encode ($ result));   

I get a popup from the widget, but no content, when I select the empty list box The one who pops up, defines "undefined", explicitly:

  log (ui.item? "Selected:" + ui.item.label + ui.item .value: "None selected was input," + this.value);   

I have checked to send and receive the Jason in firebug / web dev plugin in Firefox, / p>

  0: object data: text I value: "1" label: "Cyprus"    

My answer was found here: < / P>

I believe that do not use array_push.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -