Note that there are some explanatory texts on larger screens.

plurals
  1. POObject not posting correctly with AJAX
    primarykey
    data
    text
    <p>I have a simple function that compiles values and ids of multiple inputs into an object, then passes them to an AJAX function. Unfortunately, I cannot get the data to post correctly. The processing page is definitely called and the variables make it to the js (the object looks correct in the console), but all the variables seem to be blank on the processing page.</p> <p>scripts:</p> <pre><code>$("#" + buttonId).find(".submitValue").each(function() { inputId = $(this).attr("id").replace(buttonId + "-", ""); inputValue = $(this).val(); var data = {}; data[inputId] = inputValue; dataObject.push(data); }); $.post( 'ajax/' + buttonId + '.php', { 'nextForm': formNumber, dataObject: dataObject }, function (response) { $("#" + buttonId).append(response); } ); </code></pre> <p>relevant php processing page (there are many more variables than this, but it all looks the same - the ids in this example are "timeBlockLocation", "appointmentAddress1", "appointmentAddress2") - connection has been created</p> <pre><code>$nextForm = $connection-&gt;real_escape_string($_POST["nextForm"]); $timeBlockLocation = $connection-&gt;real_escape_string($_POST["timeBlockLocation"]); $appointmentAddress1 = $connection-&gt;real_escape_string($_POST["appointmentAddress1"]); $appointmentAddress2 = $connection-&gt;real_escape_string($_POST["appointmentAddress2"]); </code></pre> <p>Here is the var_dump on the processing page for $_POST:</p> <pre><code>array(2) { ["nextForm"]=&amp;gt; string(1) "6" ["dataObject"]=&amp;gt; array(3) { [0]=&amp;gt; array(1) { ["timeBlockLocation"]=&amp;gt; string(1) "1" } [1]=&amp;gt; array(1) { ["appointmentAddress1"]=&amp;gt; string(4) "TEST" } [2]=&amp;gt; array(1) { ["appointmentAddress1"]=&amp;gt; string(5) "TEST2" } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload