Problem using the structure returned by the ajax request

I'll send an ajax request that calls a method in a CFC.  The method executes a query and returns data.  I want to use the option of 'success' of the ajax call to display the return value "myString" in an empty div.  But nothing appears.  Everything else works.  Shouldn't the ajax call back for me "myString" and values "myNumber" which I can then use?  Or do I have the wrong syntax?

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script>
  function getMyData()  
  { 
  $.ajax({
  type: "post",
  url: "test.cfc",
  dataType: "json",
  data: {
  method: "getMyData",
  city: 'Hartford'
  }
  , success: function(data) {$('#result').html(myString);}
  , error: function(data) {$('#result').html('That failed');}
  });
  $('#anotherDiv').html('Goodbye');
  }
  </script>
</head>
<body>

<a href="javascript:()" onclick="getMyData();">
   <div>Click here</div>
</a> 

<div id="result"></div>
<div id="anotherDiv"></div>

<cfcomponent>
  <cffunction name="getMyData" access="remote" returntype="struct" returnformat="json">
    <cfset var stcRetVal = StructNew()>
        <cfset stcRetVal.myString = "Hello">
        <cfset stcRetVal.myNumber = 75>
    
        <cfquery datasource="#application.mainDS#">
  insert into test 
            (city) 
            values 
            (<cfqueryparam value="#arguments.city#" cfsqltype="cf_sql_varchar">)
  </cfquery>


  <cfreturn stcRetVal>
  </cffunction>
</cfcomponent>

If your function should return you structure JSON like:

{

'myString': 'Hello,'

"myNumber": 75

}

When you succeed, you do:

success: {function (data)}

$('#result').html (myString);

}

whence "myString"?  All that gets you back is in this object 'data '.  So, you might be able to do it instead.  Try to console.log (data) inside your success Manager.

success: {function (data)}

$('#result').html (.myString data);

}

Tags: ColdFusion

Similar Questions

  • problems using the snap have amd, playback of Jpeg files

    Original title: I'm having problems using the component feature snap-in.

    Sometimes a single document disappears. When this happens while the document program is managed by then will not work. The document seems to be flying around the office. The last time this happened I had a doc JPEG upward and now I can't see what is JPEG. I don't know why the document wants to fly around, and I don't know how to get my use of the JPEG back.

    Hey Graham,.

    To view all jpeg images in the Viewer Windows photo or any other photo software visualization, you must configure this software as a default value in the default programs.

    Check out the link that allows you to configure the program as default.

    http://Windows.Microsoft.com/en-in/Windows7/change-which-programs-Windows-uses-by-default

    You can try to run the Aero Troubleshooter and see if that makes a difference.

    http://Windows.Microsoft.com/en-in/Windows7/open-the-Aero-Troubleshooter

    If the problem persists, provide us newspapers observer of events, as well as the error message if you receive a message.

    http://Windows.Microsoft.com/en-in/Windows7/open-Event-Viewer

  • I'm having a problem using the slideshow module in LR 6.3. The slideshow contains the background image as one of the images to display. Earlier, I had created a slideshow of practice and the background image was not displayed as an image in itself. How to

    I'm having a problem using the slideshow module in LR 6.3. The slideshow contains the background image as one of the images to display. Earlier, I have created a slideshow of practice and the background image was not displayed as an image in itself. How to make it behave?

    Another approach, perhaps a little more elegant (?). Create a collection that includes images for the slideshow. Include the background image in the collection. Drag the background image in the Panel to designate. Then, remove this image from the collection and create the slide show. I just tried and it works, too.

  • Popup error when using the AJAX or update Action for the region or a State

    Hello

    I had a problem with an application that I developed and I was banging my head against the wall with this for some time without success. Several pages in my application rely on the use of AJAX to refresh a region on the page with the updated data, running every 5 seconds. I have the following code in the foot in my region:

    var refresh_region = function (region_in) {
        try {
            jQuery(region_in).trigger('apexrefresh');
        } catch (e) {
            //Suppress error messages
        } finally {
            setTimeout(function() {refresh_region(region_in)}, 5000);
        }
    }
    refresh_region('##REGION_STATIC_ID#');
    
    
    

    What is happening is that I often have a popup with the title "Message from Web page:" and one of the descriptions following error (with the last being the most common):

    • : Error - HTTP Version not supported
    • Error: error - unknown

    The problem is that this page is used on the kiosks without keyboard, and once the error popup is displayed, the page continues to answer and user interaction to click on the Ok"" button. Another question, which is even more frustrating, is that these windows will accumulate above the other nearly one hundred sometimes profoundly, to the point where, sometimes, I need to force, exit the browser or restart the kiosk. There are also cases where the entire application stops responding and none of the pages will load. The only way to solve this problem is to have my DBA restart Glassfish. He went through some of the papers, but he sees nothing specific that helps him understand why he keeps to himself, but he believes that all these popups eat connections until the server runs.

    This has been a recurring topic since the app went live and I had hoped that with the help of a block try {} catch {} would prevent these popups errors but no luck. I also made a copy of the page today and refresh moved dynamic Action using the timer plugin but the popup always appears. I am following up to see if it happens more often than the AJAX approach.

    In the end, there are two issues here:

    1. What causes the error in the first place?
    2. How can I prevent the error popup windows until I can find #1

    I have tried everything I can find online to disable popups, all of this without a bit of luck:

    • Using try {} catch {}
    • Disable script debugging in Internet Explorer
    • Uncheck 'display a notification of every script error '.
    • Catch the window.onerror event

    Does anyone have any suggestions on how I can avoid these popups?

    I have a copy of the application on apex.oracle.com:

    • Workspace: SCCC_TEST
    • User/Pass: TEST/test
    • Page: 5

    Thank you!

    Once I started to think the ajax Manager that I started, I was wondering if ajax would actually raise an error at all, and it is not just the success of shooting when but throwing an error because it cannot handle the return (error page html for example). I'm not sure.

    You can try to use this code, which will replace the current call and will call _Appel with your own parameters. _Appel is a private member is not accessible so it's probably the best alternative. Not really a hack in my book. The structure is in place, then why not.

    //preserve original function
    var asw_orig = apex.server.widget;
    //override existing function
    apex.server.widget = function(pName, pData, pOptions){
      var lOpts = pOptions;
      //set the error handler function
      lOpts.error = function(){alert("this is my error handler function");};
      //pass along the variables to the original call
      asw_orig(pName, pData, lOpts);
    };
    

    I wondered if maybe the session may have expired at a certain time and therefor, you found these errors, because the update is not aware of this and therefore makes invalid calls. Just throw something out there.

  • Problem: Using the command 'msg' with 'system Exec.vi.

    I try to write to the LabView code that takes advantage of the 'Exec.vi System '. For the moment, I have tried to use it to ping machines, return the command ipconfig and run through the code example that provides NEITHER.

    I would use the "msg" command used on Windows operating systems to send a message to several machines on our network at a time. Warning that we're about to update a program and that they should disconnect, things like that.

    I tried to use the command 'msg' LabView maintains return errors. I also wrote a quick command as follows file:

    @echo we
    CD c:\Windows\System32\
    Msg.exe /server:localhost * test

    When I run the batch of windows, it runs. When I launch from LabView (using the Exec.vi system), it fails.

    Potential quirks:

    I discovered in a different place under a machine to receive these messages they need to have a registry entry:

    "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" and have a DWord value called "AllowRemoteRPC' = 1.

    Note that "/ Server: localhost" might be "/ server: anycomputer" and the "*" is used as a wildcard character that sends a message to anyone who is connected to this computer. Also note that the 'test' is the message to send.

    Any ideas why I'm having a problem?

    TL; Dr.: "System Exec.vi" does not have the command "msg". Why is this?


  • Problems using the tools of accessibility on PDF interactive with complex tables and fields in form (in AcroDC)

    Hello

    Although I worked earlier in the accessibility check (will be abbreviated as "axs" later) before using the Checker axs documents, what he used Windows and Acrobat XI a year ago. I am now responsible for creating interactive forms that are available on a Mac (platform I prefer), that have been designed only visually in InDesign, then transferred in Acrobat X or XI where someone placed the form fields and then handed to me to settle the tab for end-users order and make them accessible to people with disabilities (Government org). Problem is, some of these documents are extremely dense arrays, in which each cell of the table is a checkbox or a radio button I have several questions:

    (1) the order of reading has something to do with the tab order? (I spent hours to get the tab order works the way it should and do not know if by clicking any axs tool that will change and cancel all my work.)

    (2) I need to mark an entire page, more or less, as a table but when I am in reading of editing tool (TURO), I get the crosshairs of hanging around that object, but when I go to playback control panel, and then click Table, everything is deselected and nothing else happens. My goal is to get to the table to label the lines headings and column editor, etc. What is going on? What I have to do all this in the Panel tags instead?

    (3) in the Panel tags, I see a table with 30 lines, which is what I have visually, but when I select the TRs and TDs nothing gets selected on the form, so I don't know how to get the content of the form "in" these TDs... it is a very complicated document and I'm getting confused. " Not a lot of experts out there on Axs AND Acrobat DC dealing with this and I'm frustrated! There's a guy on Lynda.com including videos watched re: similar topics, but in his case, he got a table which is just text and it is small, and his method is by selecting each cell of the table with the cross and he the tags labeling a 'cell', and then go in the Panel and work on the appropriate type / # Table elements slide autour stuff in the appropriate lines etc. My picture has lines 30 and 13 columns, and approaching the fields of interactive form in most of the cells... This is not practical, but do not know if there is a quick/accurate way to get the table recognized otherwise?

    Any help is appreciated...

    Sorry,

    Very frustrated

    Yes, treating large complex tables can be the chore of accessibility PDF much time and frustrating. First question - these tables of data or layout tables? Several forms are organized visually using layout tables, but do not really present data organized in rows and columns. Marking this content in a table would be run against failure condition Matterhorn Protocol 15-004, "content is marked as a table of information that is not organized in rows and columns. Instead, work in the Tags pane, drag all the elements of content out of the structure of the table and re-tag/organize according to the needs. The Suite of PDF/UA reference has an example of form (document 10) that you can refer to-although its layout tables is relatively low. A simple structure, detroit forward should be easier to fix at a large table and also easier for a user to read assistive technology.

    However, if these are legitimate data tables... I find the reading pane to be worse than useless. The Tags pane sets the reading order for assistive technology. Something that I find useful is to break down a complex table into manageable pieces, clean up the subtables can recombine. You can also consider assessing NetCentric CommonLook - I do not use it, but it has a good reputation for working with arrays. I don't think it's available for Mac, however.

  • Columns of Union two problem using the TO_CLOB function

    Hello

    Let me start by you (a simplified version of) showing the query I'm running:

    SELECT
    l.Person,
    TO_CLOB(l.letter_code ||) "letter has been sent.") Note
    letters l

    UNION

    Select
    n.Person
    n.Note
    n notes

    And here's the table structure

    LETTERS)
    l.Person varchar2 (10);
    l.letter_code varchar2 (2);
    *)*

    NOTES)
    n.Person varchar2 (10);
    CLOB n.note;
    *)*

    Each request runs on its own without any problem but when I union together I get a ' * ORA-00932: inconsistent data types: expected - got CLOB * "error. I can't understand what is the cause. The TO_CLOB in the first query is to convert the varchar2 column in a CLOB then why would he be oppose to be clauses with the second query?

    Any advice would be much appreciated! Thanks :)

    You may not use the set operations, UNIONS, MINUS, INTERSECT with CLOB columns etc. simple as that.

  • Continuing the audio problems using the Kona card

    MAC PRO 2 x 2.93 GHz 6 Core

    12 GB 1333 DDR3 Ram MJZ

    Kona card 3

    Kona driver 10.3.1

    Adobe for Kona 10.3.0 utilities

    Graphics Quadro 4000 card

    Video player Apple XServe raid

    more 2 TB G-raid & 3, 7200 RPM internal 2 TB disks

    10.7.4 OS

    CS6.0.1.31

    So I've dealt with this problem since I downloaded and started using the Kona 3 with PPCS6.0.1 drivers

    Often when I start my computer after it turned off the day before and restart the Prime Minister in the same project that I left that worked very well.  I'm broken audio playback mode.  When I check my audio computer system to preferences they mysteriously turned on in Kona, which is what causes the problem.

    I try to change their return to the line output line, preferneces and close then reopen and that the switch did not and they are back to Kona.

    I repair permissions and restart and make the change again... sometimes when I do this I get a kernel panic, so need to stop and start again.  Someties it will fix the problem today, sometimes not.  Today, after the kernel panic, everything seems to work properly.

    It's a bit boring and a 15 to 20 minutes exercise every morning.  Of course, I could leave my machine all night, but I'd sure appreciate all the ideas on how to fix this ongoing issue.

    I've turned into a bug report today, because I think that it is indeed a bug somewhere.

    THX... Jim Watt

    I found a post in the apple forum that solved this problem...

    If you have problems with your sound 'exit by default' in Snow Leopard, try the following...

    Go to your hard drive (root level) and open the library folder. Open the Preferences folder, and then open the Audio folder.

    Remove the two preference files in the Audio file:

    -com.apple.audio.DeviceSettings.plist

    -com.apple.audio.SystemSettings.plist

    Restart your mac, and I hope that your problems will be solved.

    This solution worked for me, and I hope that it will be too much for you.

  • has could not initialize photoshop because of a problem using the engine of color adobe (Win 7)

    Running the latest version of Photoshop CS5 and added a second quad and 4 monitors graphics card more.  Now the PS does not start and I get the error message "could not initialize photoshop because of a problem in using the adobe color engine."
    Computer has 2 cards NIVDIA Quadro4 NVS420 graphics with 8 monitors Samsung SyncMaster 1920 x 1080.  If I turn off 4 monitors for CS5 to start normally.  I don't have to remove the extra graphics card.  When I extend the desktop again to all 8 monitors I get the above error.

    How do I troubleshoot the problem?  It's Photoshop, NIVDIA or Windows 7?

    A display profile is corrupt (in the sense that we've not seen before), or the OS color engine is returning false data about the installed profiles and displays.

    My guess is that it's the operating system and displays.

    It could be a driver issue, but I suspect it is the operating system.

  • Problem using the View object for validation

    Hello
    I defined a form of simple to practice swing. It has an entity object and two objects in view. One of these objects in view is an editable VO based on area of occurrence, and the other has a simple 'select count (*)' table. I defined a validation of the method on one of the EO attributes to see how to use the VO for validation. However, I set the Module of the Application to use both from my point of view. As much as I undrestood, when I define a VO for AM, AM will instantiate it the first time it starts to run. Here is the code inside the method for the FirstName attribute validation:

    / * Validation for first name method
    */
    public boolean validateFirstName (String data) {}
    ViewObject vo is getDBTransaction () .getRootApplicationModule () .findViewObject ("CountEmployeeInstance");.
    If (vo == null) {}
    System.out.println ("vo is null");
    }
    else {}
    vo.executeQuery ();
    If (vo.hasNext ()) {}
    System.out.println ("count =" + ((CountEmployeeRowImpl) vo.next ()) .getCount ());
    }
    else {}
    System.out.println ("vo has no other");
    }
    }
    Returns true;
    }

    The problem is that vo.executeQuery () does not return a any folder. In fact the vo.hasNext () returns false and I get the message "vo has had no news" on the console. Please be careful that the sql statement in the VO is always SELECT COUNT (*) and it returns a record. I found that if I use vo.closeRowSet () vo.executeQuery () before everything is working properly.
    Please tell me what is my problem and why it works that way?
    Best regards
    Alireza Vali

    Sorry Alizera, on transit to the officer of the WATCH.

    This can be the 'compulsory' classic of the substitution of issue position iterator. Take a look at the post following Sascha Herrman who addresses the issue and as solution suggests the creation of a new RowSetIterator to avoid the problem:
    Re: viewObject.executeQuery does not work the second time

    There are a number of positions where Sascha has solved this problem so a search can be useful to the effort on your part.

    Next post gives an interpretation of long-term by myself if accidentally you use getRowSetIterator that you might find useful, but essentially Sascha answer is correct, "to create a new RSI", I was talking a slightly different point:
    Re: [SOLVED] Re: how to browse all lines

    Let us know how you go.

    See you soon,.

    CM.

  • Problems using the iPad Pro notes app

    I have a new iPad Pro (IOS 9.2), but the notes app doesn't seem to work properly with a pencil. There is no line doodle icon and I can't write with a pencil. Can I use the pencil to 'click' on the functions as "BOLD" and new, but not as a pencil. Someone at - it experience with this and how can I solve this problem?

    Have you updated the Notes app in the app itself.

  • Equium L40 problems using the recovery disk

    Hello

    I wonder if anyone can help me?

    I want to restore my computer but when I put the recovery disk in I select the cd/dvd rom drive by pressing f12 at startup.
    I also maintained pressed C when I lit. I select the disc I want to start the computer, it goes to a black screen, then it loads just windows up as usual.

    I phoned with Toshiba for help and all they could tell me was that as another drive worked on my computer, it isn't a problem with the disk drive, but a problem with the disc and it will cost me 30 quid for a new!

    Is anyone able to give me any help

    Thank you

    Hello

    If I understand your message, you are not able to recover the laptop using the Toshiba disc. Is this good?

    Well, in your case I recommend to start from another original Windows XP CD bootable disc or Vista DVD or a Linux drive to test if the CD/DVD drive can handle this drive.

    In this case, you can test if your CD/DVD drive is faulty or if the problem is related to the Toshiba DVD recovery.

    Welcome them

  • Problem using the Keithley 6487 pAmmeter with supply voltage.

    I try to use a Kiethley 6487 to bias a photon detector in my lab and I am new to LabVIEW. So far, I've been able to get current the ammeter readings, but I can't increase the supply voltage. The code I came up with so far is able to start communication over distance with the device but returns an error when you use the vi ramp. Here is the error I get:

    1074135024 error has occurred in KE6485 configure Source Ramp.vi

    Possible reasons:

    Driver status: (Hex 0xBFFA0010) invalid value for the parameter or property.

    I removed the piece of code related to the drafting of my main block diagram and changed my global variables to the constants. Any help on this would be highly appreciated.

    Thank you
    Cameron


  • M277dw: Reset zero problem using the USB to M277dw

    Hello, I'm just trying to see if anyone else has had this problem. I use the laserprinter HP M277dw and use a current running nine Imac El captain. If I print anything on my printer and then decide to reboot my computer for some reason any, if I keep the USB cable connected to my computer that is connected to the printer, the computer hangs on reboot. It is the same on a full stop to the low and new start up as well. It's almost as if the printer is not disconnected somehow when I shut down or restart. The solution I found is to unplug the printer USB whenever I have to restart or shut down and then reconnect to the computer up and running again. My feeling is that this is related to the El captain, but I can't say for sure. Anyone else see this problem?

    Hi @andrewdawson11,

    Welcome to the Forums of HP Support! I see that you have problems, turn off the Mac, it crashes on restart when the printer is connected by a USB connection. I will definitely do my best to help you. If this helps you to find a solution, please click on the button "Accept as Solution" down below in this message. If you want to say thanks for my effort to help, click on the 'Thumbs Up' to give me a Kudos.

    Run Apple updates.

    You download and install the latest drivers for the printer? If the latest driver is not installed, which can cause this problem. Here is the link if you have not already: HP Easy Start.

    Make sure that the correct driver is added.

    Click on the Apple menu, click System Preferences. Click on Printers & Scanners, highlight the name of the printer on the left side and right side of the screen it should show the name of the printer. (Laserjet M277dw)

    If the full name of the printer is not correctly, delete and add the printer name back from the list. Click on the sign - to remove the driver and then click on the + sign to add the driver might have to drop-down list to select the name of the printer to add a click.

    If the problem persists, try the following:

    Fix permissions of the drive on the Mac:

    Close all applications.

    In the Apple menu, click OK, click Applications, and then click utilities.

    Double-click disk utility.

    Highlight your hard drive / partition on the left.

    Click on check and then repair disk permissions.

    Restart the computer...

    Reset the printing system:

    Note: This will remove all printers in the print and Fax/Scan, any printer deleted can be re-added later by clicking the sign plus (+) symbol.

    Click on the Apple icon and then click on System Preferences.

    Click on Printers & Scanners.

    Make a right click (or Ctrl + click) in the left white side panel, and then click Reset printing system.

    Click OK to confirm the reset.

    Type the name and the correct password.

    Click OK to reset the printing system.

    Then click on the sign to add the driver, highlight the printer +. (you may need to click the drop down menu to select the printer name) Then click the Add button.

    Test the printer and try to restart the Mac again.

    If there is anything else I can help you, let me know. Thank you.

  • Problem using the Overdrive Media Console software program

    When I try to download audio files using the Overdrive Media Console program (used by the public library in my area) I get the error message "error) xC)) D2781: problem occurred in the identification of rights management digital retriving.»   What is the reference for this?

    Hello

    • What is the format of audio file you were trying to play?
    • What version of Windows are you using?

    You can follow below link that can help you to solve your problem:

    http://www.Microsoft.com/windows/windowsmedia/player/Webhelp/default.aspx?&mpver=11.0.5721.5145&ID=C00D11E2&ContextId=71&OriginalID=C00D2781

Maybe you are looking for

  • screenshot on ios 3 watch

    Hello How to take a screenshot on os shows 3 and where is the list of friend at Apple Watch 3 Thank you

  • OfficeJet Pro 8600 spits out a blank second page when receiving faxes

    I have a brank new Officejet Pro8600 and it's the same as my last HP all-in-one has started doing.  Even if he receives only one fax from page, it seems to read as two pages and also spits out a blank second page. My frustration is more, because I ju

  • HP 250 g2 i3 wi fi drivers problems

    Hello I tried all of these operating systems: windows 7 ultimate 32/64 bit and windows 7 pro 64-bit I am installing a Wi fi drivers for this laptop, but all the time, it gives me this error: -This program may not be installed properly -Reinstall usin

  • Sysprep and Windows Update

    I need some Windows 7 machines to the test.  I have licensed ten machines.  How to keep the machine base up-to-date on Windows Update? I would like to create a basic machine that Windows 7 is installed.  I like to keep up-to-date via Windows update. 

  • Best way to decide what programs are safe to delete?

    I did everything you can imagine to improve performance on my PC and finally facing the last hurdle. There are WAY to many installed programs. I removed everything that I use on a regular basis. Now I am faced with many programs that I use that came