php - Using the JQuery .Ajax() method? -
i creating site user fills out form, has data sent php script , display result in div , have been struggling complete while now. below code have created:
the button activates function:
function callfunc() { var testvar = "example 01"; $.ajax( { url: "public/includes/usercreate.php", type: "post", data: testvar, success: function(html) { $('#web_content').html(html); } }); }; the php file this:
<?php $test = $_post['testvar']; echo $test; ?> for reason though doesnt work. mean doesnt inject value of echo command div, if take out variable data php , have echo simple element, work , injects echo value div, below code run:
<?php $test = $_post['testvar']; echo "<h3>user ???? created.</h3>"; ?> i think because not sending data correctly, tell me correct way send data php script , also, how send more 1 variable?
you need data: { testvar: "example 01"} key value pair. generate query string parameter testvar=example%2001
Comments
Post a Comment