0

I'm trying to process a page which contains data from one form (user input fields), data from other elements on the page (options) and a JQuery variable (array). I'm trying to figure out the best way to send these to a PHP file to process.

If I link the submit button to the user input form it will send all those fields but not the variable or the user options.

If I trigger an action on the button click I can call a JQuery function which sends the variable by POST/AJAX to the PHP script.

$(document).on('click', '#submit', function(){
        $.ajax({
            url:"processdata.php",    
            type: "post",    
            data: {dataList: dataList},
            dataType: 'text',
            success:function(result){
                //success
            }
        });
});

Is there a way to make a single click post all three sets of data at once? With three post operations I would get three separate results to the JQuery script and I'm not sure how to handle that.

pickarooney
  • 385
  • 2
  • 18
  • You can get all the data using JS/jQuery and send them through a single AJAX call. Is this a large form? – El_Vanja Dec 17 '20 at 16:49
  • How do you build `dataList`? – RiggsFolly Dec 17 '20 at 16:50
  • There are just 6 user fields, two options and a multimensional array (dataList) which is passed to this page (the one with the form data) from localSession. To send all in one call, does each parameter/field have a separate data entry in the AJAX call or can they be concatenated together? – pickarooney Dec 17 '20 at 17:07

0 Answers0