We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10525
    • 247 Posts
    I have a small form. It is populated using standard procedures.

    My ajax file includes the following lines (there too many to paste all here):
    global $modx;
    global $scriptProperties;
    global $placeholders;
    
    $return .= "start";
    $orderStatus = getOrderStatus($id); // db query
    
    $placeholders['orderStatus'] = $modx->getOption("orderStatus", $scriptProperties, $orderStatus);
    $tpl = $modx->getOption('tpl',$scriptProperties,'myForm');
    $return .= $modx->getChunk($tpl, $placeholders);
    $return .= "<br/>fin";
    return $return;

    When I load this form in a standard page it works fine.
    I have also loaded it into a lightbox popup (Fancybox, inline) and that works ok.

    But I want to refresh the form each time I display it, to make sure it is up to date, so I am trying to load it into the Fancybox popup via ajax (ie generate it dynamically, instead of just when the page refreshes). Now, everything appears in the popup window except for the template and placeholder values.

    Output:
    start
    fin

    I have followed the recommended procedure for using a templateless doc to load an ajax file, to ensure that I am in the MODx session and have all the relevant objects available.

    Are there any known issues/procedures relevant to this scenario that I might have missed?...
      • 4172
      • 5,888 Posts
      what is your snippet-call on your ajax-resource?
      what does getOrderStatus($id) do? the code?
      where is $id coming from?
      why do you

      global $modx;
      global $scriptProperties;
      global $placeholders;
      

        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 10525
        • 247 Posts
        Bruno,

        thanks for responding. I sat down and laboriously extracted code, wrote details of what I was doing and, just when I was about ready to post, discovered my problem: In testing the inline form with the button to make it appear, I had set the form to display:none;. In testing with ajax, it was still set to display:none;

        One of these fantastic schoolboy errors that you kick yourself for but at the same time laugh with relief that it was nothing worse :-D

        So to conclude: I have a fancybox popup which displays a form generated from an ajax call. The php file queries MySQL, populates placeholders and assembles them in a template chunk. The form is submitted via ajax as well (closing as it does so), updating the database and then updating values in the parent page. All works perfectly.