Alpha Video Training
Results 1 to 7 of 7

Thread: value of AJAX callback in Javascrpt

  1. #1
    VAR
    Real Name
    Mike Reed
    Join Date
    Apr 2000
    Location
    Phoenix, AZ
    Posts
    660

    Default value of AJAX callback in Javascrpt

    I have a button on a list control that needs to do a couple of things. This is for a training app that has scholarships.

    When the button is clicked an ajax callback is run that first determines if the student has already registered for the class. If so, then a javascript message is returned to the user and the process should end.

    If they haven't already registered, then the ajax callback will return a number (as a string) if they have any scholarship money available to reduce the cost of the class.
    I convert the string to a value and deduct it from the class fee. The next step would be to open a Stripe window for credit card processing.

    I don't know how to write this. In other words how do I set a javascript variable from an ajax callback?

    Thanks,

    Mike
    Mike Reed
    Phoenix, AZ

  2. #2
    "Certified" Alphaholic
    Real Name
    Lee Vasic
    Join Date
    May 2010
    Location
    Salt Lake City
    Posts
    1,207

    Default Re: value of AJAX callback in Javascrpt

    You can use e.javascript e.javascript = "alert('hello');"
    e.javascript - if you want to send some javascript back to the browser, set this property.

  3. #3
    VAR
    Real Name
    Mike Reed
    Join Date
    Apr 2000
    Location
    Phoenix, AZ
    Posts
    660

    Default Re: value of AJAX callback in Javascrpt

    I didn't do a good job of explaining what I am trying to do.

    I am trying to do a stripe credit card charge. I have this javascript function as a part of the UX control for the Stripe checkout Genie where it asks for the amount to be charged.

    The issue is that I have to do an Ajax callback first to find out how much money is available as a scholarship. So in the case below the javascript variable n is supposed to have the charge amount. The charge amount is the course fee minus and scholarship amount. So the question is how to I perform an Ajax function to get the scholarship value?

    function getAmount() {
    // get value and convert decimal value to cents, required by Stripe
    var n = {Dialog.object}.getValue('list::CLASSSCHEDULE::course_fee') - {dialog.object}.ajaxCallback('','','ScholarshipAmt','','',{chunkedResponses: {allow: false},deviceOfflineFunction: function() { }});

    n *= 100;
    return Math.round(n);
    }

    Clear as mud, huh?
    Thanks,
    Mike
    Mike Reed
    Phoenix, AZ

  4. #4
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,355

    Default Re: value of AJAX callback in Javascrpt

    Hi Mike,

    Forgive my ignorance about this, but can't you call the stripe function from within the callback
    that has determined the cost of the course fee to be deducted ?

  5. #5
    "Certified" Alphaholic
    Real Name
    Lee Vasic
    Join Date
    May 2010
    Location
    Salt Lake City
    Posts
    1,207

    Default Re: value of AJAX callback in Javascrpt

    In the callback after you get all the amounts that you need from the database, you can use xbasic to do the calculation.
    Then put that result in a e.control(field) (A hidden field on the UX). Then, in your javascript function, you can referenced that field.

  6. #6
    VAR
    Real Name
    Mike Reed
    Join Date
    Apr 2000
    Location
    Phoenix, AZ
    Posts
    660

    Default Re: value of AJAX callback in Javascrpt

    Thank You I'll give that a try.

    Peace,
    Mike
    Mike Reed
    Phoenix, AZ

  7. #7
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,643

    Default Re: value of AJAX callback in Javascrpt

    You can also pass values between xbasic and your UX or grid using state variables.

Similar Threads

  1. a5.ajax.callback
    By GGandhi in forum Application Server Version 11 - Web/Browser Applications
    Replies: 3
    Last Post: 08-26-2014, 09:25 PM
  2. Set value via ajax callback
    By rjackson@arach.net.au in forum Application Server Version 11 - Web/Browser Applications
    Replies: 2
    Last Post: 05-23-2014, 11:24 PM
  3. In a grid's button click, how do i run ajax callback then run report then callback?
    By WindForce in forum Application Server Version 11 - Web/Browser Applications
    Replies: 3
    Last Post: 08-09-2012, 07:19 PM
  4. help with ajax callback
    By madtowng in forum Application Server Version 11 - Web/Browser Applications
    Replies: 13
    Last Post: 05-28-2012, 01:21 PM
  5. Ajax Callback
    By lvasic in forum Application Server Version 10 - Web/Browser Applications
    Replies: 2
    Last Post: 08-18-2011, 08:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •