Jquery autocomplete - json

I want to implement AutoComplete search functionality to form field using freely available JQuery. Now, I have a fully functional, simplified code that works perfectly with a .cfm page, but I have been struggling to convert it to a cfc file, namely to convert ColdFusion data into a JSON !
here is the working code:
test-autoc.cfm
<script type="text/javascript" src="scripts/jquery-1.3.1.min.js"></script>
<script src="scripts/jquery.autocomplete.js"></script>
<link rel="stylesheet" href="css/autocomplete.css" type="text/css" />
<script type="text/javascript">
$(document).ready(function() {
    $("#topic").autocomplete(
                "auto-complete-q.cfm",
            minChars:2,
            delay:200,
            autoFill:false,
            matchSubset:false,
            matchContains:1,
            cacheLength:10,
            selectOnly:1
</script>
<form name="testa" id="testa" action="#" method="get">
<p>
<label for="topic">topic</label>
<input type="text" name="topic" id="topic" />
</p>
</form>
auto-complete-q.cfm
<cfinvoke component="Application" method="password" returnvariable="password">
<cfinvoke component="Application" method="username" returnvariable="username">
<cfsetting enablecfoutputonly="true">
<cfparam name="URL.q" default="">
<cfquery name="titleq" datasource="datasource" username="#username#" password="#password#">
SELECT title
FROM latestnews
WHERE title LIKE <cfqueryparam value="%#URL.q#%" cfsqltype="cf_sql_varchar">
</cfquery>
<cfoutput query="qryGetCountry" maxrows="10">
#titleq.title#
</cfoutput>
and the one I have been struggling with
test-autoc1.cfm
<script type="text/javascript" src="scripts/jquery-1.3.1.min.js"></script>
<script src="scripts/jquery.autocomplete.js"></script>
<link rel="stylesheet" href="css/autocomplete.css" type="text/css" />
<script type="text/javascript">
$(document).ready(function() {
    $("#topic").autocomplete(
                "auto-complete-q.cfc?method=gettitles&returnFormat=JSON",
            minChars:2,
            delay:200,
            autoFill:false,
            matchSubset:false,
            matchContains:1,
            cacheLength:10,
            selectOnly:1
</script>
I also tried adding source: and aditional {} to the JavaScript code above, but had no luck.
<form name="testa" id="testa" action="#" method="get">
<p>
<label for="topic">topic</label>
<input type="text" name="topic" id="topic" />
</p>
</form>
auto-complete-q.cfc
<cffunction name="gettitles" access="remote" returntype="array">
    <cfargument name="searchparam" type="string" required="false" default="test jjjjj test">
    <cfset var titleq = "">
    <cfset var result = arrayNew(1)>
  <cfquery name="titleq" dataSource="datasource">
    SELECT title
    FROM latestnews
    WHERE title LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="%#arguments.searchparam#%">
  </cfquery>
  <cfloop query="titleq">
    <cfset arrayAppend(result, titleq.title)>
  </cfloop>
  <cfreturn result />
</cffunction>
Although the code does not generate any error, for some reason it always selects the default value set in cfargument!?
I also tried replacing LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="%#arguments.searchparam#%"> with a literal value (LIKE "%whatever%") and in that case cfc actually returns that value if something is typed in the search field. However, when selected returned value outputs the following code  <wddxPacket version='1.0'><header/><data><array length='1'><string>test jjjjj test</string></array></data></wddxPacket> !?
As I can see something is missing in both CFC and JavaScript code!?
CF version - CF MX 7.0.2

I don't think returnformat=JSON works in CF7, you need at least ColdFusion version 8 for that to work.
yep, I think you're right.
You will need to use some third party code to convert your data into JSON, there are a few cfc's out there that can do the trick
ok, definitelly I'm gonna learn more about it. In the meantime, what if I replace <cfreturn result /> with say <cfoutput>#result[1]#</cfoutput><cfabort /> it would be a handy workaround for the WDDX issue!? That being said, I am still stuck with the default value issue, given that every time no matter what is typed into the search box the default value set in cfargument will be passed.!?? I would like to solve this issue first! Could someone point out which file is causing the problem, cfc of javascript?

Similar Messages

  • Jquery autocomplete

    Hi jari,
    Thanks for your reply.
    i am displaying first_name from employees table.
    i am sending you my code.
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/themes/redmond/jquery-ui.css" type="text/css" />
    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("jquery", "1.4.2");
      google.load("jqueryui", "1.8.0");
    </script>
    <script type="text/javascript">
    $(function(){
    $("#P500_FIRST_NAME").autocomplete({ // Change P73_STATE to your text item id
      source: function(r,s){
       $.ajax({
        type:"POST",
        url:"wwv_flow.show",
        dataType:"json",
        data:{
         p_flow_id:$v('pFlowId'),
         p_instance:$v('pInstance'),
         p_flow_step_id:$v('pFlowStepId'),
         x01:$v('P500_FIRST_NAME'), // Change P73_STATE to your text item id
         p_request:"APPLICATION_PROCESS=P500_AUTOCOMPLETE"},// Change P73_AUTOCOMPLETE to your On Demand Process name
        success:function(d){
         s($.map(d.row,function(l){
          return{
           label:l.FIRST_NAME,value:l.FIRST_NAME // Change STATE_NAME to column name you return from On Demand Process
      open:function(){$(this).removeClass("ui-corner-all").addClass("ui-corner-top");},
      close:function(){$(this).removeClass("ui-corner-top").addClass("ui-corner-all");}});
    </script>Application process
    DECLARE
      l_sql VARCHAR2(32000);
    BEGIN
      l_sql := '
        SELECT FIRST_NAME
        FROM EMPLOYEES WHERE FIRST_NAME LIKE ''' || UPPER(APEX_APPLICATION.G_x01) || '%''
        ORDER BY 1
      APEX_UTIL.JSON_FROM_SQL(l_sql);
    EXCEPTION
      WHEN OTHERS THEN
        HTP.p ('{"row":[]}');
    END;Thanks & Regards
    Vedant

    Hi jari,
    Thank you so much for your help. Now its working.
    jari i have one more question related to jquery autocomplete.
    i am following http://tylermuth.wordpress.com/2010/03/16/jquery-autocomplete-for-apex/ this link to fetch mutiple value based on search field.
    i have followed all the steps but i did some changes. i have deleted
    x02: 'foo',
                x03: $('#P2_DEPARTMENT').val() lines from code because i was not getting why these lines are used.if this is required what changes i do in my code so its work fine for me?
    i am sending you code
    i am fetching FIRST_NAME,LAST_NAME,EMAIL FROM EMPLOYEES TABLE.
    my code is not working.
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="#WORKSPACE_IMAGES#jquery.autocompleteApex1.1.js"></script>
    <link rel="stylesheet" type="text/css" href="#WORKSPACE_IMAGES#jquery.autocomplete.css" />
    <script type="text/javascript">
    $(document).ready( function() {
        $("#P501_SEARCH").autocomplete('APEX', {
                apexProcess: 'EMPLOYEES_EXTENDED',
                width: 400,
                multiple: false,
                matchContains: true,
                cacheLength: 1,
                max: 100,
                delay: 150,
                minChars: 1,
                matchSubset: false
        // the following statement sends the result to multiple items on the page.
        $("#P501_SEARCH").result(function(event, data, formatted) {
            if (data){
                $("#P501_FIRST_NAME").val(data[1]);
                 $("#P501_LAST_NAME").val(data[2]);
                $("#P501_EMAIL").val(data[3]);
    </script>APPLICATION PROCESS
    declare
         l_search varchar2(255);
    begin
        execute immediate 'alter session set NLS_SORT=BINARY_CI';
        execute immediate 'alter session set NLS_COMP=LINGUISTIC';
        l_search := replace(wwv_flow.g_x01,'*','%');
        for c1 in (select first_name||' '||last_name name,first_name,last_name,email
                     from employees
                    where first_name like '%'||l_search||'%'
                       or last_name like '%'||l_search||'%')
        loop
            htp.p(c1.name||'|'||c1.first_name||'|'||c1.last_name||'|'||c1.email);
        end loop;
    end;

  • Developer-Online New Tutorial Released: Create a Flickr gallery using jquery and JSON

    Create a Flickr gallery using jquery and JSON
    Hello everyone, In this tutorial I'll show how is simple to build your Flickr photo gallery using jQuery framework and JSON. We'll see how to setup thumbnail's numbers, convert your RSS Flickr in a JOSOn format and display theme. Thank You for your attention!
    Posted on:                                       2010-01-11 10:20:48
    Author: patrizio Quatrini
    Best Regards
    Waleed Barakat

    Heya,
    When I first read your post I originally thought you were posting a tutorial about whether a chosen username has already been resigtered or not on the signup page like this tutorial:
    http://DwFAQ.info/signup_demo.php
    Spry Check Username Availability
    Date Created: Sunday, July 5, 2009 2:29 PM
    Then after looking at the page you've linked to and trying to understand the objective of the tutorial I've noticed that you are talking about something like this:
    http://DwFAQ.info/home.php?id=7
    Spry Search
    Date Created: Sunday, March 1, 2009 8:51 PM
    It's pretty simple to do with the link I've referenced. Simply create your database with populated tables, use the mentioned script to convert the database data into xml syntax, then enter your dynamic database script as the location of the xmlDataSet in the spry page linked.
    View source on this page which shows the non-destructive filter in action to see how it's done! You can also spice it up a little for products, etc. by using this method. The key is to create a dynamic xml syntax from your database and then use the dynamic xml script location as your xmlDataSet in the search page.
    I have an example of the auto suggest search on my homepage http://DwFAQ.info
    On the top-left side of the page click on the link that says Search Tutorials to reveal the search form. Then start typing characters into the search box to see the entries instantly filter according to the characters that are typed. You can also filter further by clicking on the category checkboxes to filter by keywords AND category.
    You can view the source code on my homepage to see the location of the dynamic xml syntax referenced as the xmlDataSet location and how it was implemented into the site.

  • Jquery autocomplete not working within WCI 10g R3

    Hi we have written below code that works fine outside of portal to load an autocomplete. But with in portal it gets stuck on java script call to some defualt java script that WCI renders while typing in autocomplete text box. We tested on a blank community page.PLease let su know if there is anything OOB in WCI for autocomplete text box or how can we get this to work.
    Code for JSP
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ taglib prefix="html" uri="http://jakarta.apache.org/struts/tags-html" %>
    <style type="text/css" media="all">
              /* NOTE: Do not remove this style. The "listHiliteText" style is used
              to highlight search terms in the result's extract section.
              For example, a search for "Plumtree" might return:
              ...The <span class="listHiliteText">Plumtree Corporate Portal...
              .listHiliteText {background=lightblue}
              .bcTrail { font:normal 10px Verdana; padding-left:5px; color:#3D3937; padding-right:2px; }
         .mainContent { padding : 0px 8px 2px 5px;margin: 10px 0px 0px 5px;font : normal 11px Verdana;color : #3D3937; }
         .Normal { font : normal 11px Verdana; color : #000000; }
              </style>
    <link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
    <script src="jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="jquery.autocomplete.js" type="text/javascript"></script>
    <script id="search" type="text/javascript">
    $(document).ready(function() {
    $("#searchQuery").autocomplete('http://10.61.239.222:8989/CRIPSearch/CRIPBasicSearchSavedRecords.jsp');
    </script>
                             <div class="bcTrail">Home &gt; Basic Search</div>
                             <div class="mainContent">
                                  <html:form name="CRIPBasicSearch" action="/CRIPBasicSearchAction.do" type="com.wcisearch.form.CRIPBasicSearchForm">
                                       <strong>Enter your query here:</strong><br>
                                       <br>
                                  <!--     <html:text property="searchQuery" />-->
    <input type="text" name="searchQuery" id="searchQuery" value="" />
    <html:hidden name="start" value="1" property="start"/>
                                       <html:hidden name="count" value="10" property="count"/>
    <html:submit value="Search"/>
                                       <br>
                                       Tips for searching
                                       <br>
                                       <br>
                             </html:form>
    </div>
    view source in portal::::: Java script error in below javascript is being called when typing in the autocomplete text box:
    <script type="text/javascript">
    //Gray out and disable anchor links by passing in the object id
    disableAnchor = function(objId, disable)
    var obj = document.getElementById(objId);
    if(obj != null)
    if(disable)
    var href = obj.getAttribute("href");
    var onclick = obj.getAttribute("onclick");
    //Store the previous value in a new attribute
    if(href && href != "" && href != null)
    obj.setAttribute('href_bak', href);
    if(onclick != null)
    obj.setAttribute('onclick_back', onclick);
    obj.setAttribute('onclick', "void(0);");
    obj.removeAttribute('href');
    obj.style.color="gray";
    else
    //Swap back in the original href and onclick values
    var hrefBack = obj.getAttribute("href_bak");
    var onclickBack = obj.getAttribute("onclick_back");
    if(onclickBack !=null )
    obj.setAttribute('onclick', onclickBack);
    obj.removeAttribute('onclick_back');
    if(hrefBack !=null )
    obj.setAttribute('href', hrefBack);
    obj.removeAttribute('href_bak');
    obj.style.color="blue";
    </script>

    ptportletservices.js:
    line 588 (this is 6.1 mp1). no idea if this helps you or not btw.
    //modified by JDC
    PTPortletServices.prototype.RaiseWindowEvent = function(objEventArgs)
         try{
              if (this && this.RaiseEvent)
                   this.RaiseEvent(this.WindowEventURN, 'on' + arguments[0].type, arguments[0]);
              else if (document.PCC && document.PCC.RaiseEvent)
                   document.PCC.RaiseEvent(document.PCC.WindowEventURN, 'on' + arguments[0].type, arguments[0]);
         }catch(e){}
    }

  • Looking for best jQuery.ajax & JSON code validators for VStudio 2013 SP Dev

    Hi All,
    As a new SharePoint 2013 developer I’m looking for the best Visual Studio 2013 Intellisense Extensions or code validators for:
    1. jQuery.ajax
    2. JSON
    3. JSON.stringify
    The reason for this is I sometimes make silly syntax mistakes that take hours to correct. For example the text marked in green below show
    the small errors I made yesterday, and got no help from Visual Studio.
    ************************Start Of Code************************
    var call = jQuery.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.WebProxy.invoke",
    type: "POST",
    data: JSON.stringify(
    "requestInfo": {
    "__metadata": {
    "type":
    "SP.WebrequestInfo"
    },        //should be R
    "Url":
    "http://services.***********/?$format=json",
    "Method":
    "GET"
    heaaders:             
    //two a's{                                                                                                       
    "Accept":
    "application/json;odata=verbose",
    "Content-Type":
    "application/json:odata=verbose",   
       //should be ;    
    "X-RequestDigest": $("#__REQUESTDIGEST").val()
    call.done(function
    (data, textStatus, jqXHR) {                   
    if (data.d.Invoke.StatusCode == 200) {                          
    var categories = JSON.parse(data.d.Invoke.Body);
    var message = jQuery("#message");
    message.text("********* service:");
    message.append("<br/>");
    jQuery.each(categories.value(
    function (index, value) {     //should
    be ,    
    message.append(value.*********);
    message.append("<br/>");
    } else {
    var message = data.d.invoke.body;   
                //should be capital letters
    alert("Call failed. Error: " + message);
    //should be errorThrown
    call.fail(function
    (jqXHR, textStatus, errorThrow) {                     
    var response = JSON.parse(jqXHR.responseText);
    var message = response ? response.error.message.value : textStatus;
    alert("Call failed. Error: " + message);
    ************************End Of Code************************
    Visual Studio didn’t highlight any of the errors I made. The only help I got was from a message
    box with the message “invalid character” (see screenshot below).
    Even with Fiddler it was impossible to see where the errors were. Last week I had a similar problem with a much larger block of code. One syntax mistake that was not highlighted by Visual Studio cost me hours of lost time.
    I hope you can help
    CEStar

    Hi,
    As this question is more relate to Visual Studio, I suggest you post it to Visual Studio Development Forum, you will get more help and confirm answers from there.
    What’s more, I have seen a similar post from you in the link below, please check whether Crystal’s post is helpful:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/dbde39a0-18a5-4e15-9b5b-6b41cc4350d0/help-finding-the-best-intellisense-extensions-or-code-validators-for-visual-studio-2013?forum=visualstudiogeneral
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Patrick Liang
    TechNet Community Support

  • Using APIs with Edge (JQuery and JSON)

    Hi I am very new to APIs but I have a pretty basic understanding and I want to figure out how I could use them in Edge. I following the following tutorial and have tried to modify it for my liking: http://www.gotoandlearn.com/play.php?id=168
    Essentially, I am trying to pull in the most recent Flickr phots on Flickr.com. Check out my files in the Zip below and the URL I have been testing on:
    http://dl.dropbox.com/u/9159616/flickr-test.zip
    http://createmate.co/flickr-test/
    Thanks for your help!
    Ada,

    Hi Adam,
    So, i downloaded your project files and i tested with another flickr address.
    My test comes from: http://api.jquery.com/jQuery.getJSON/
    Using your "slide" symbol, the code tested was:
    $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?",
                 tags: "mount rainier",
                 tagmode: "any",
                 format: "json"
               function(data) {
                 $.each(data.items, function(i,item){
                                var s = sym.createChildSymbol("slide", "Stage");
                                 s.$("photo").css({"background-image": "url('"+item.media.m+"')"});
                                 s.$("title").html(item.title);
                   if ( i == 10 ) return false;
    Your slide symbol works fine.
    Therefore, your flickr address is not correct.
    If you copy and paste your flickr address within your address bar (Safari), Flickr returns: jsonFlickrApi({"stat":"fail", "code":98, "message":"Invalid auth token"})
    You can look at this tutorial: http://net.tutsplus.com/tutorials/javascript-ajax/the-ultimate-guide-to-decoding-the-flick r-api/

  • JQuery GRID JSON data

    I have following code to use JQuery GRID.
    I tried to use XML data first, using DataXML.cfm which works.
    After that, I tried to use JSON using following code which is the same I just change datatype to json.
    I use url to test my cfm file which returns data.
    Can any one help me or suggestion to see where I can look the following javaScripts or cfm file for JQuery GRID to find a solution,
    Your help and information is great appreciated,
    Iccsi,
    following is cfc file
    <cffunction name="getLoc" access="remote" returntype="any" returnformat="json">
    <cfquery name="qryLoc" datasource="Mysource">
    SELECT invid, invdate, amount, tax, total, note  FROM invheader
    </cfquery>
    <cfoutput>
    <cfset i = 1>
    <cfset data = ArrayNew(1)>
    <cfloop query="qryLoc">
    <cfset row = StructNew()>
    <cfset row["invid"] = "#qryLoc.invid#">
    <cfset row["invdate"] = "#qryLoc.invdate#">
    <cfset row["amount"] = "#qryLoc.amount#">
    <cfset row["tax"] = "#qryLoc.tax#">
    <cfset row["total"] = "#qryLoc.total#">
    <cfset row["note"] = "#qryLoc.note#">
    <cfset data[i]  = row>
    <cfset i = i + 1>
    </cfloop>
    <cfreturn #serializeJSON(data)#>
    </cfoutput>
    </cffunction>
    following  is jGrid.cfm
    $(function () {
        $("#list").jqGrid({
            url: 'http://127.0.0.1/test/Example.cfc?method=getLoc',
            datatype: 'json',
            colNames: ['Tax', 'Inv No', 'Date', 'Notes', 'Total', 'Amount' ],
            colModel: [
                { name: 'tax', width: 80, align: 'right' },
                { name: 'invid', width: 55 },
                { name: 'invdate', width: 90 },
                { name: 'note', width: 150, sortable: false },
                { name: 'total', width: 80, align: 'right' },
                { name: 'amount', width: 80, align: 'right' }
            pager: '#pager',
            rowNum: 10,
            rowList: [10, 20, 30],
            sortname: 'invid',
            sortorder: 'desc',
            viewrecords: true,
            gridview: true,
            autoencode: true,
            caption: 'My first grid'
    </script>
    </head>
    <body>
    <table id="list"><tr><td></td></tr></table>
        <div id="pager"></div>
    </body>
    </html>
    XMLData.cfm is following data
    <cfcontent type="text/xml;charset=utf-8" />
    <rows>
       <page>1</page>
       <total>1</total>
       <records>1</records>
       <row id='1'>
           <cell>1</cell>
           <cell>07/26/2013</cell>
           <cell><![CDATA[Client 1]]></cell>
           <cell>700</cell>
           <cell>140</cell>
           <cell>840</cell>
           <cell><![CDATA[Nice work!]]></cell>
       </row>
    </rows>
    my cfc file returns following data
    [{"tax":10.00,"invid":1,"invdate":"July, 24 2013 00:00:00","note":"Test","total":10.00,"amount":10.00},{"tax":50.00,"invid":2,"invdate":"J uly, 03 2013 00:00:00","note":"test","total":100.00,"amount":20.00},{"tax":50.00,"invid":3,"invdate":" July, 15 2013 00:00:00","note":"test","total":100.00,"amount":20.00}]

    Did you look at the example in the jqGrid Demos page? The answer is there.
    Open http://trirand.com/blog/jqgrid/jqgrid.html
    Open Chrome Developer Tools
    See what is the URL when you click the next page button on the grid?
    http://trirand.com/blog/jqgrid/server.php?q=1&_search=false&nd=1374957231342&rows=10&page= 2&sidx=id&sord=desc
    If you click the previous page:
    http://trirand.com/blog/jqgrid/server.php?q=1&_search=false&nd=1374957248411&rows=10&page= 1&sidx=id&sord=desc
    As you can see the page value in the query string change from 2 to 1.
    Then, see the PHP code. The page variable is use to retrieve data.
    That means if you give a number of rows, the grid does not calculate page number automatically. You should do the calculation from the CFC.

  • JQuery JSON set items

    Hi all,
    I used to use the less functional ajax call using:
    var ajaxRequest = new htmldb_Get(null, &APP_ID., 'APPLICATION_PROCESS=APP_MY_OD', 1);
    //add all my variables I wish to access in my OD
    ajaxRequest.add('P1_X', $v('P1_X'));
    data = ajaxRequest.get();
    //my OD then sets a string formatted JSON for return using apex_util.json_from_items('P1_X') and adds to session
    //with the return string in JSON format set the items value using json_SetItems
    json_SetItems(data);
    So I understand that the function json_SetItems parse the string when in JSON format.
    My question, is there a similar json_SetItems function that will set items when a jQuery object JSON is returned? The one that's returned from the following:
    $.ajax({
      type: 'POST',
      data:
    // etc...
    success: function (data) {
        //data is now a jQuery object, are there any built in functions for this?
    I understand I could always make the dataType 'text' which would return a string and call the json_SetItems but was hoping to use dataType 'JSON'
    Thanks
    Spam

    "data" is not a jQuery object. It is the returned data in a type specified by the dataType parameter. jQuery docs:
    dataType (default: Intelligent Guess (xml, json, script, or html))
    Type: String
    The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string).
    The success parameter is defined as this:
    success
    Type: Function( PlainObject data, String textStatus, jqXHR jqXHR )
    A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, formatted according to the dataType parameter; a string describing the status; and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object.
    So I'm not sure what exactly it is you're after. If you want plain text back then request it as such. If you'd rather have JSON then go with that.

  • Json encode and Recordsets

    Hi,
    I have a jquery autocomplete that requires a json response for a remote database. I am not familiar with json, so, I'm not sure if I'm using json_encode correctly.
    The jquery script on my input page is straight from a working demo, so the problem seems to be with the json encode on the "search" php page.
    This is from the Search.php page:
    mysql_select_db($database_connmal, $connmal);
    $query_rsname =
    sprintf("SELECT act_info.first FROM act_info WHERE act_info.insight = %s
    OR act_info.insight = 0", GetSQLValueString($colname_rsname, "int"));
    $rsname = mysql_query($query_rsname, $connmal) or die(mysql_error());
    $row_rsname = mysql_fetch_assoc($rsname);
    $totalRows_rsname = mysql_num_rows($rsname);
    echo json_encode($row_rsname);
    Thanks,
    Tim

    The output on the search.php page is:
    {"name":"name1"}
    Only the first result shows from the recordset. I can echo everything in the recordset with:
    do {
    echo json_encode($row_Recordset1);
    } while ($row_rsexercises = mysql_fetch_assoc($Recordset1));
    but I don't think that's the right way to do it. It gives the following:
    {"name":"name1"} {"name":"name2"} {"name":"name3"} {"name":"name4"}
    Neither way is being picked up by the requesting page. Tried a couple of other things with no luck.
    (Tested the input page by changing the url to the Jquery demo search.php page, that works fine.)

  • How to POST JSON to CFHTTP

    Hi,
    I need help to write RESTful cfc to accept call from jquery in JSON format.
    This is approximate format of the structure as an argument to the cfc:
    returns:
    code: 200  // Successfull
    data: {
        "success": true,
        "result": {
            "questions":[
                {"question_id": "1", "question_answert": "some text..."},
                {"question_id": "2", "question_answer": "some text..."},
                {"question_id": "3", "question_answer": "some text..."}
    This is cfc to parse JSON:
    <cffunction output="yes" name="verifyQuestions" access="remote" produces="application/json" returnType="string" httpmethod="post">
                  <cfargument name="questanswers" type="string" restargsource="path"/>
            <cfset cfData = DeserializeJSON(questanswers)>
            <cfset colList = ArrayToList(cfData.COLUMNS)>
            <cfset qIdx = ListFind(colList, "question_id")>
            <cfset aIdx = ListFind(colList, "question_answer")>
              <!--- loop through the structure and validate it here against db --->
            <cfloop index="i" from="1" to="3">
                question id: #cfData.DATA[i][qIdx]#
                answer: #cfData.DATA[i][aIdx]#
            </cfloop>
            <cfreturn VARIABLES.vcDeserilized>
        </cffunction>
    This is a cfm file to test RESTful cfc:
    <cfhttp url="http://10.200.5.2/rest/login/questions/" method="post">
    <cfhttpparam type="formfield" value="[{question_id:'4', question_answer:'test 4'},{question_id:'6', question_answer:'test 6'},{question_id:'8', question_answer:'test 8'}]" name="questanswers">
    </cfhttp>
    <cfoutput>#cfhttp.filecontent#</cfoutput>
    When run the file above I am getting
    {"Message":"JSON parsing failure: Expected '\"' at character 3:'q' in [{question_id:'4', question_answer:'test 4'},{question_id:'6', question_answer:'test 6'},{question_id:'8', question_answer:'test 8'}]"}
    Also, from what I understand debug from RESTful cfc's is problematic. Does my cfc syntax look correct to accept JSON formatted object?
    Thanks,
    Gena

    The JSON that you are sending in the cfhttpparam is invalid, test the string out with IsJSON or use a tool like http://jsonlint.com/ to find the error.

  • Autocomplete to Combobox, where is the LOV...

    Apologies for the title of the post...
    I am hoping I am just missing some minor item, and a push in the right direction will get me working again.
    A few years back, most likely under Apex 4.0, I started using Jquery - Autocomplete for looking up employee names, hostnames, etc. This used some Javascript that someone had posted (don't recall who), and it worked pretty well. I would add a stanza like this to the page def (to be run after the page loads). The X02 passed some extra info to the on demand procedure to help with the search.
    $("#P28_REQUESTOR").autocomplete('APEX', {
                    apexProcess: 'PERSON_SEARCH_ACTIVE',
                    width: 600, multiple: false,
                    x02: 'Hostmaster:Owner Ok',
                    minChars: 3, selectFirst: false,
                    formatItem: function(row, i, max, term) {
                            if  ( row[1] > 0 )
                                return row[0]+" "+row[2]+" "+row[3];
                             return row[0]},
                    max: 100,
                    cacheLength: 1
       $("#P28_REQUESTOR").result(function(event, data, formatted) {
             $("#P28_REQUESTOR_ID").val(data[1]); });The Person Seach Active on demand procedure was something like: (Note - some details have been left out to give a better example - in the end, it doesn't matter at all)
    declare
       target_name  varchar2(255);
       scope_id    varchar2(16);
    BEGIN
       OWA_UTIL.mime_header ('text/html', FALSE);
       HTP.p ('Cache-Control: no-cache');
       HTP.p ('Pragma: no-cache');
       OWA_UTIL.http_header_close;
       target_name :=  wwv_flow.g_x01;
       scope_id := wwv_flow.g_x02;
       Simon.Apex_People_Select.Trace('On Demand called for ' ||Target_Name || '/' || scope_id);
       FOR c IN (SELECT search_name,display_name,result_id
                   from table
                 (Simon.HM_Network_Maint.search_network(scope_id, Target_Name)))   
       LOOP
             HTP.p(c.search_name ||
                   '|' || c.result_id ||
                   '|' || c.display_name );
       END LOOP;
    END;The g_x01 value is what the user is typing into the text box - once they hit three characters, it gets sent to Oracle for processing via the on demand procedure. The g_x02 (and 03, 04,..) are additional parameters - perhaps from a parent LOV. General concept with the returned data is the first element is the text to be searched, the second is the actual value (typically an integer - primary key), and the third value is what ends up in the text box once a value is selected (the searching value often has additional identifying info.)
    This approach worked pretty well, although it did not play well with cascading LOVs. But once I upgraded to Apex 4.2, I started hitting other issues with jQuery version differences, and some odd failures. To make matters worse, the original developer of the Javascript module, abandoned it - was not doing additional work with it.
    Combobox
    I did NOT want to re-invent the wheel, and it seemed to be a much better approach to move into PlugIn world - ideally using a plugin that someone ELSE wrote and was maintaining. I looked at the LOV Friendly Autocomplete plug in - and even installed it a few places - and discovered that it did not play well with my earlier autocomplete code.
    My concern with using the LOV Friendly Autocomplete - is that I didn't know how to provide any of the "Target Name" search info to the LOV (since that is what is being typed by the user at the time).
    I also started looking at the Combobox plug in - which seemed even closer with Lazy Loading=Yes (I also liked the ability to add new items on the fly) - but I was not sure how to provide the "Target Name" info the the Pipelined function that generates the list of values.
    I want to get rid of all of my old Autocomplete javascript and move to one (or more) plugins - (Which is why the details above don't matter, just trying to provide some background)
    Is this a good direction (Combobox or LOVFA)? How/Where do I connect my search (lov generation)?
    Edited by: Jon Finke on Jan 9, 2013 5:52 PM

    I've found the LOV (list of values from Forms) but I've
    notice that the search functionality is missing.
    (I'm talking about the "drop as " button LOV option on a form in JClient for ADF from "Data Control Palette"
    Best regards,
    Lucian

  • Jquery uisng combox!!

    Hi All,
    I am trying to implement the Jquery using combox and i had followed the steps given in Jquey.com
    But wheni had tried to implement it is throwing error at this line is undefined.
    $.widget( "ui.combobox", {
    (code}
    can i get any other example to achieve this?
    Thanks,
    Anoo..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Anoo wrote:
    Hi VC,
    I had alreday went thru this link. here i want to know what exact the problem isSo is that not any good for you?
    1. Initally i had done thru DTHMLX combox every thing is fine but problem is when ever we have records more than 1000 records the system is getting hanged.
    I am not sure what coudl be the exact problem.
    2. In order to ovecome this i have started wroking on Jquery Autocomplete So we are using smart text box instated of Smart list box.
    In this case it will show the corresponding selection values insted of all values.
    3. But the team is prefering for Combx box autocomplte insted of jquery. What is Combx box autocomplte? is it DTHMLX?
    4. Do you have any idea why DHTMLX is slow for fetcing the records.I have no idea about DHTMLX and never used it, there might be several things behind the performance issues such as sql query, browser, or even the plugin itself(DHTMLX)

  • Is this OnDemand process secure?

    Hello,
    I'm using the jQuery autocomplete method along with an OnDemand application process to return a list of user's based on whats being typed in my input box. I want to make sure that it's not vulnerable to sql injecton. Can anyone tell me if this is safe or not?
    Application Express 3.2.1.00.12
    Here's the code in question.
    Application Process:
    DECLARE
      l_sql VARCHAR2(32000);
    BEGIN
      l_sql := '
       select full_name, position_name, rowid
         from emp
        where 1=1
          and upper(full_name) like ''%'|| upper(apex_application.g_x01) || '%''
       order by 1
      APEX_UTIL.JSON_FROM_SQL(l_sql);
    EXCEPTION
      WHEN OTHERS THEN
        HTP.p ('{"row":[]}');
    END;jQuery:
    <script type="text/javascript">
    $(function(){
    $("#P300_NEXT_APPROVER").autocomplete({
      source: function(r,s){
       $.ajax({
        type:"POST",
        url:"wwv_flow.show",
        dataType:"json",
        data:{
         p_flow_id:$v('pFlowId'),
         p_instance:$v('pInstance'),
         p_flow_step_id:$v('pFlowStepId'),
         x01:$v('P300_NEXT_APPROVER'),
         p_request:"APPLICATION_PROCESS=EmployeeAutocomplete"},
        success:function(d){
         s($.map(d.row,function(l){
          return{
           label:l.FULL_NAME +" - "+ l.POSITION_NAME, number:l.ROWID
      select: function( event, ui ) {
       $( "#P300_NEXT_APPROVER" ).addClass("hide").val("");
       $( "#P300_NEXT_APPROVER_TITLE" ).html( ui.item.label);
       $( "#P300_NEXT_APPROVER_ROWID" ).val( ui.item.number);
       return false;
      delay: 500,
      minlength: 2,
      open:function(){$(this).removeClass("ui-corner-all").addClass("ui-corner-top");},
      close:function(){$(this).removeClass("ui-corner-top").addClass("ui-corner-all");}});
    </script>Thanks in advance,
    Daniel

    Hi,
    You could create application item. Set app item Session State Protection to Restricted - May not be set from browser
    Then change process
    DECLARE
      l_sql VARCHAR2(32000);
    BEGIN
      :MY_APP_ITEM := '%' || upper(apex_application.g_x01) || '%';
      l_sql := '
       select full_name, position_name, rowid
         from emp
        where 1=1
          and upper(full_name) like :MY_APP_ITEM
       order by 1
      APEX_UTIL.JSON_FROM_SQL(l_sql);
    EXCEPTION
      WHEN OTHERS THEN
        HTP.p ('{"row":[]}');
    END;Regards,
    Jari
    My Blog: http://dbswh.webhop.net/htmldb/f?p=BLOG:HOME:0
    Twitter: http://www.twitter.com/jariolai

  • How to create custom search box will allow up to 60 alphanumericcharacters & User can input a minimum of 1 character and the system will pull back an exact match on the sequence entered.

    Hi,
    Can anyone please help me in creating the Custom Search box with below mentioned functionality
    "The search box will allow up to 60 alphanumeric characters.User can input a minimum of 1 character and the system will pull back an exact match on the sequence entered"

    Hi Pradeep,
    Find the complete JQuery AutoComplete function with along with different events in it like focus, select, open and close. You can modify this code as per your requirement.
    $("#ddlSearchTextBox").autocomplete({
    source: function (request, response) {
    var getUrl = "<site URL>";
    $.ajax({
    url: getUrl,
    type: "GET",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    data: {
    featureClass: "P",
    style: "full",
    maxRows: 10
    dataFilter: function (data, type) {
    return data.replace(/\\'/g, "'");
    success: function (data) {
    response($.map(data.d, function (result) {
    return {
    label: result.Last_Name + ", " + result.First_Name,
    value: result.id
    focus: function (event, ui) {
    $("#ddlSearchTextBox").val(ui.item.label);
    return false;
    minLength: 1,
    select: function (event, ui) {
    $("#ddlSearchTextBox").val(ui.item.label);
    return false;
    open: function () {
    $("#ddlSearchTextBox").removeClass("ui-corner-all").addClass("ui-corner-top");
    close: function () {
    $("#ddlSearchTextBox").removeClass("ui-corner-top").addClass("ui-corner-all");
    Let us know if you need any further.
    Thanks, Shakir | Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

  • How do I add a testimonial comment box to my site ?

    I am currently almost finished building my site, I want to add in my footer a comment box, so the visitors can leave testimonials about my business.
    I would like the data that they enter to automatically appear in another div and fade in and out.
    So basically two different divs one that holds the comment box, and the other that cycles through all the testimonials one at a time and fades in and out.
    The only problem is I have no idea where to start.
    Can someone tell me each subject that this involves and what I should reference to get this started and finished. Like I said I know how to build a basic site but I dont know anything about adding a comment box or have that inputted data display in another div automatically and cycling throught them all.
    This site at the bottom of the page has a display similar to what I am thinking off but doesnt have the comment box, but that is basically what I am trying to figure out how to do, the customer quotes fade in and out. I would just like another section next to it for customers to add there comments and have the list automatically update and scroll through them like this site is doing
    So if someone could just explain what topics I should be researching specifically I would greatly appreciate it.
    http://www.filesonic.com/file/45975527/v9.1.157.Cracked-NOY.part1.rarhttp://www.vsplash.com/

    What you need is server-side scripting and the use of a library like Jquery.  You need the server side scripting to send the information to a database to be saved (assuming you want to keep the comments) and then JQuery and javascript will process and write to the page.  I don't want to scare you too much, but this is not a topic for beginners because it involves interaction between the languages.  I have provided 2 links below for reference:
    http://net.tutsplus.com/tutorials/php/asynchronous-comments-with-jquery-and-json/
    http://www.99points.info/2010/07/facebook-style-wallpost-and-comments-system-using-jquery- ajax-and-php-reloaded/

Maybe you are looking for

  • Down saving from CS5 to CS4 in a batch

    Hello! I have a large volume of CS5 files to downsave to CS4 so they can be used on another machine. Is it possible to do this in a batch? I've tried a couple ways so far and I'm definitely doing something wrong as the new files still tell me they we

  • Sender SFTP Adapter channel is not polling for files

    Hello All, Couple of SFTP sender adapter channel was failing in Developent system with u201Cdirectory listingu201D error.All SFTP sender channels stopped polling for the files in Developent system  . We were unable to find the reason for adapter fail

  • Step by Step guide to transfer movies to iPod - using PC

    I am looking for a step by step guide to transfer movies to my iPod... i have a PC and need to transfer DVD movies to my iPod. i know that there is a process, somewhat tedious, but i cannot find instructions anywhere on the steps to do it. i purchase

  • Assign custom infoset to PA30 free search

    Hi Could you please let me know how to assign  the custom infoset to PA30 free search? Thanks

  • DNG files wont import

    I've been shooting with Hasselblad for a few years, the workflow is as follows. Import 3fr direct into Lightroom or when shooting tethered direct into Phocus I export a dng from Phocus and import the dng into Lightroom. Sometime ago (over a year ago)