Re: [WebDNA] WebDNA jQuery JSON javascript stuff

This WebDNA talk-list message is from

2010


It keeps the original formatting.
numero = 105081
interpreted = N
texte = Hi Big thanks to both you (for pointing it out) and Stuart (for writing it). Works a treat and solves my issue, esp. given that Donovan confirmed I couldn't use the plugin I was trying to use since WebDNA can't handle the json encryption. Now just one request Stuart - Any chance you could have it handle a value and name separately? Ie. The search finds a state, but what if I needed it to display the state yet carry over an ID in the form post? Thanks, on 18/3/10 11:13 PM, christophe.billiottet@webdna.us at christophe.billiottet@webdna.us wrote: > There is an autosuggest in the site resources download. It as been writte= n by > Stuart and works quite well: http://www.webdna.us/page.dna?numero=3D5 >=20 > - chris >=20 >=20 > On Mar 18, 2010, at 0:01, Diane Blackmore (Cohesion) wrote: >=20 >> Hi >>=20 >> My experience with ajax is limited but I have done some. I needed an aja= x >> tool to allow an =8Catuosuggest=B9 function (like Google has to make suggest= ions >> after a few letters/words have been typed). Found one (and a good one) b= ut I >> cannot get it to work when using a URL to gather the data object rather = than >> just using a string in the js itself. >>=20 >> Jquery tool is AutoSuggest: Docs found at >> http://code.drewwilson.com/entry/autosuggest-jquery-plugin >> I=B9m using it under jQuery 1.3.2. >>=20 >> Here is the code that works; >>=20 >>> >>=20 >> Or in raw format; >>=20 >>> >>=20 >>=20 >>=20 >>=20 >> Looks fine, except that when db is actually complete there=B9ll be 2500 sc= hools >> so we don=B9t want that listed on the page. Therefore we need to call the >> search on another page... Which is what I usually do, however in this >> instance I don=B9t seem to be getting the opportunity to =8Cclean=B9 the resul= t of >> stuff that I don=B9t want =AD like the opening =B3=B2 which th= e js >> above won=B9t want to see at all, and maybe some line-feeds or other chara= cters >> also.=20 >>=20 >> Usually clean data with replace(/\s*/, "") >>=20 >> Code to use a URL rather than a data string as above is; >>>=20 >>> >>=20 >>=20 >> ... Where =8C_findSchools.csn=B9 is the page doing the WebDNA processing as >> follows; >>=20 >>=20 >>> >>> [search=20 >>> db=3D../db/schools.db&geschooliddatarq=3D1&eqsch_livedatarq=3DT&asschool_name= sort=3D >>> 1][founditems]{value: "[schoolid]", name: "[school_name]"}[hideif >>> [index]=3D[numfound]],[/hideif][/founditems][/search] >>=20 >> However this doesn=B9t come back with a valid format even when the results= are >> pasted straight in to the =B3_findSchools.csn=B2 page. Tried adding >> [SETMIMEHEADER name=3DContent-type&value=3Dapplication/json] since the PHP >> example had a similar thing but no luck there either. >>=20 >> PHP =8Cexample=B9 provided by plugin app developer reads; >>=20 >>> >> $input =3D $_GET["q"]; >>> $data =3D array(); >>> // query your DataBase here looking for a match to $input >>> $query =3D mysql_query("SELECT * FROM my_table WHERE my_field LIKE >>> '%$input%'"); >>> while ($row =3D mysql_fetch_assoc($query)) { >>> $json =3D array(); >>> $json['value'] =3D $row['id']; >>> $json['name'] =3D $row['username']; >>> $json['image'] =3D $row['user_photo']; >>> $data[] =3D $json; >>> } >>> header("Content-type: application/json"); >>> echo json_encode($data); >>> ?> >>=20 >>=20 >>=20 >> Basically, can anyone tell me how I can get the data back in the JSON fo= rmat >> it needs, without the extra WebDNA stuff that it doesn=B9t need. >>=20 >>=20 >> Thanks heaps if you can help, >>=20 >>=20 >>=20 >> >=20 > --------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > archives: http://mail.webdna.us/list/talk@webdna.us > old archives: http://dev.webdna.us/TalkListArchive/ > Bug Reporting: http://forum.webdna.us/eucabb.html?page=3Dtopics&category=3D28= 8 >=20 >=20 Associated Messages, from the most recent to the oldest:

    
  1. Re: [WebDNA] WebDNA jQuery JSON javascript stuff ("Diane Blackmore (Cohesion)" 2010)
  2. Re: [WebDNA] WebDNA jQuery JSON javascript stuff (Donovan Brooke 2010)
  3. Re: [WebDNA] WebDNA jQuery JSON javascript stuff (christophe.billiottet@webdna.us 2010)
  4. Re: [WebDNA] WebDNA jQuery JSON javascript stuff (Tom Duke 2010)
  5. Re: [WebDNA] WebDNA jQuery JSON javascript stuff ("Terry Wilson" 2010)
  6. Re: [WebDNA] WebDNA jQuery JSON javascript stuff (Donovan Brooke 2010)
  7. [WebDNA] WebDNA jQuery JSON javascript stuff ("Diane Blackmore (Cohesion)" 2010)
Hi Big thanks to both you (for pointing it out) and Stuart (for writing it). Works a treat and solves my issue, esp. given that Donovan confirmed I couldn't use the plugin I was trying to use since WebDNA can't handle the json encryption. Now just one request Stuart - Any chance you could have it handle a value and name separately? Ie. The search finds a state, but what if I needed it to display the state yet carry over an ID in the form post? Thanks, on 18/3/10 11:13 PM, christophe.billiottet@webdna.us at christophe.billiottet@webdna.us wrote: > There is an autosuggest in the site resources download. It as been writte= n by > Stuart and works quite well: http://www.webdna.us/page.dna?numero=3D5 >=20 > - chris >=20 >=20 > On Mar 18, 2010, at 0:01, Diane Blackmore (Cohesion) wrote: >=20 >> Hi >>=20 >> My experience with ajax is limited but I have done some. I needed an aja= x >> tool to allow an =8Catuosuggest=B9 function (like Google has to make suggest= ions >> after a few letters/words have been typed). Found one (and a good one) b= ut I >> cannot get it to work when using a URL to gather the data object rather = than >> just using a string in the js itself. >>=20 >> Jquery tool is AutoSuggest: Docs found at >> http://code.drewwilson.com/entry/autosuggest-jquery-plugin >> I=B9m using it under jQuery 1.3.2. >>=20 >> Here is the code that works; >>=20 >>> >>=20 >> Or in raw format; >>=20 >>> >>=20 >>=20 >>=20 >>=20 >> Looks fine, except that when db is actually complete there=B9ll be 2500 sc= hools >> so we don=B9t want that listed on the page. Therefore we need to call the >> search on another page... Which is what I usually do, however in this >> instance I don=B9t seem to be getting the opportunity to =8Cclean=B9 the resul= t of >> stuff that I don=B9t want =AD like the opening =B3=B2 which th= e js >> above won=B9t want to see at all, and maybe some line-feeds or other chara= cters >> also.=20 >>=20 >> Usually clean data with replace(/\s*/, "") >>=20 >> Code to use a URL rather than a data string as above is; >>>=20 >>> >>=20 >>=20 >> ... Where =8C_findSchools.csn=B9 is the page doing the WebDNA processing as >> follows; >>=20 >>=20 >>> >>> [search=20 >>> db=3D../db/schools.db&geschooliddatarq=3D1&eqsch_livedatarq=3DT&asschool_name= sort=3D >>> 1][founditems]{value: "[schoolid]", name: "[school_name]"}[hideif >>> [index]=3D[numfound]],[/hideif][/founditems][/search] >>=20 >> However this doesn=B9t come back with a valid format even when the results= are >> pasted straight in to the =B3_findSchools.csn=B2 page. Tried adding >> [SETMIMEHEADER name=3DContent-type&value=3Dapplication/json] since the PHP >> example had a similar thing but no luck there either. >>=20 >> PHP =8Cexample=B9 provided by plugin app developer reads; >>=20 >>> >> $input =3D $_GET["q"]; >>> $data =3D array(); >>> // query your DataBase here looking for a match to $input >>> $query =3D mysql_query("SELECT * FROM my_table WHERE my_field LIKE >>> '%$input%'"); >>> while ($row =3D mysql_fetch_assoc($query)) { >>> $json =3D array(); >>> $json['value'] =3D $row['id']; >>> $json['name'] =3D $row['username']; >>> $json['image'] =3D $row['user_photo']; >>> $data[] =3D $json; >>> } >>> header("Content-type: application/json"); >>> echo json_encode($data); >>> ?> >>=20 >>=20 >>=20 >> Basically, can anyone tell me how I can get the data back in the JSON fo= rmat >> it needs, without the extra WebDNA stuff that it doesn=B9t need. >>=20 >>=20 >> Thanks heaps if you can help, >>=20 >>=20 >>=20 >> >=20 > --------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > archives: http://mail.webdna.us/list/talk@webdna.us > old archives: http://dev.webdna.us/TalkListArchive/ > Bug Reporting: http://forum.webdna.us/eucabb.html?page=3Dtopics&category=3D28= 8 >=20 >=20 "Diane Blackmore (Cohesion)"

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

& in Lookups (1997) WebCatalog2 Feature Feedback (1996) authorize net (2001) How true is this? (1999) Search and Show question (2003) turning every 5th line red (1999) formula??? (2000) Protecting Files (how to display vs. present a link to (2005) new WebDNA 5 command reference (2003) writing db to disk (1997) Associative lookup style? (1997) typhoon... (1997) [WriteFile] problems (1997) WebCat website for developers and hosters (2001) Stumpted Again (1997) notification solutions (1997) Show if time tags (1997) WebTV (1998) webcat- multiple selection in input field (1997) Searching an Email database (1997)