We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13507
    • 7 Posts
    A big Hi to the MODx community! grin

    I have begun building a module to handle product catalog’s. I wish to use ajax in the system, but I cannot find any info on how I get the server to receive the ajax call.

    As the module loads in a frame, through the manager scripts im not sure if I should just call a script directly from the module, or if there is a neat way prebuilt into MODx.

    EDIT:
    I want to be able to use modx to get the data from the database, so I can try to keep some form of security on the ajax part wink
    Adding a file to handle ajax in the module means I’d have to include some MODx file to init the MODx code.

    Does any one have any suggestions/comments?

    thanks
      • 13507
      • 7 Posts
      I have an additional problem shocked

      When using the prototype library with the install of MODx 0.9.6 to handle the ajax calls I cannot get it to post any data back to a script sad

      I have setup a script in the modules folder and am using this code to post back when you select an option from a select form element.

      <script type="text/javascript"  language="javascript">
      			function showTemplateVars() {
      				var tmplid = document.module.prodtypes.options[document.module.prodtypes.selectedIndex].value;
      				alert(tmplid);
      				new Ajax.Request('<?php echo $siteURL.$pm_config["path_module"]."ajax.php" ?>',
      				  {
      				    method:'post',
      				    parameters:{tmplnum:tmplid, hmmmm:'AAAArrrrrgggg' },
      				    onSuccess: function(transport){
      				      var response = transport.responseText || "no response text";
      				      alert("Success! \n\n" + response);
      				    },
      				    onFailure: function(){ alert('Something went wrong...') }
      				  });
      			}
      </script>
      


      the ajax.php file is currently a simple echo of the $_REQUEST array, so I can see if my variables are getting to my script!

      <?php
      print_r($_REQUEST);
      ?>
      


      EDIT:
      I have currently done away with AJAX updating of forms on my module, and am 50% complete Yay! laugh
      But if anyone has any info on using ajax within the manager interface Id much appreciate it.

      thanks for passing through.