How to pass PHP variable that is created after submit to jQuery -


i've beens searching answer on one, far couldn't find it. i'm trying submit form. after form submitted, message created. message should prepended table.

here code snippets:

if($ids = $threadmessageobject->insert()){     $newmessage = '<tr>                     <td class="dashcellleft">test data</td>                     <td class="dashcellright">on test date</td>                 </tr>'; } 

the above code triggered after form submitted. normally, values of form @ moment user clicks 'submit'. however, these formfields generated else's code , can't change (which means can't data).

i have feeling problem comes fact php server side, while jquery client side.

now, jquery looks this:

$(document).ready(function(){     $('#threadmessageform').submit(function(e){         e.preventdefault();         this.submit();         alert("<?php echo($newmessage); ?>");         var newmessage = '<?php echo $newmessage; ?>';         if (!newmessage) {             parent.$('.threadanswers .dash .dashcontent .infotable').prepend('<tr><td class="dashcellleft">test name</td><td class="dashcellright">on test date</td></tr><tr><td class="dashcellleft">random message!</td><td class="dashcellright">respond</td></tr>');         }         else {             parent.$('.threadanswers .dash .dashcontent .infotable').prepend(newmessage);         }      }); }); 

any appreciated!


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -